Track how much time people spend waiting for queues to be flushed
Summary: Added stats, so that we know how much people have to wait when opening plugin after we open the queue GK Reviewed By: jknoxville Differential Revision: D19598730 fbshipit-source-id: f955123f2bae5b870eada8f787385d6c0450453e
This commit is contained in:
committed by
Facebook Github Bot
parent
0ed95f2a99
commit
bdd4516dc4
@@ -192,7 +192,7 @@ class PluginContainer extends PureComponent<Props, State> {
|
|||||||
pluginKey &&
|
pluginKey &&
|
||||||
pendingMessages?.length
|
pendingMessages?.length
|
||||||
) {
|
) {
|
||||||
// this.setState({progress: {current: 0, total: 0}});
|
const start = Date.now();
|
||||||
this.idler = new Idler();
|
this.idler = new Idler();
|
||||||
processMessageQueue(
|
processMessageQueue(
|
||||||
activePlugin,
|
activePlugin,
|
||||||
@@ -202,7 +202,18 @@ class PluginContainer extends PureComponent<Props, State> {
|
|||||||
this.setState({progress});
|
this.setState({progress});
|
||||||
},
|
},
|
||||||
this.idler,
|
this.idler,
|
||||||
);
|
).then(completed => {
|
||||||
|
const duration = Date.now() - start;
|
||||||
|
this.props.logger.track(
|
||||||
|
'duration',
|
||||||
|
'queue-processing-before-plugin-open',
|
||||||
|
{
|
||||||
|
completed,
|
||||||
|
duration,
|
||||||
|
},
|
||||||
|
activePlugin.id,
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,9 +204,9 @@ export async function processMessageQueue(
|
|||||||
store: MiddlewareAPI,
|
store: MiddlewareAPI,
|
||||||
progressCallback?: (progress: {current: number; total: number}) => void,
|
progressCallback?: (progress: {current: number; total: number}) => void,
|
||||||
idler: BaseIdler = new Idler(),
|
idler: BaseIdler = new Idler(),
|
||||||
) {
|
): Promise<boolean> {
|
||||||
if (!plugin.persistedStateReducer) {
|
if (!plugin.persistedStateReducer) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
const total = getPendingMessages(store, pluginKey).length;
|
const total = getPendingMessages(store, pluginKey).length;
|
||||||
let progress = 0;
|
let progress = 0;
|
||||||
@@ -249,12 +249,13 @@ export async function processMessageQueue(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (idler.isCancelled()) {
|
if (idler.isCancelled()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
await idler.idle();
|
await idler.idle();
|
||||||
// new messages might have arrived, so keep looping
|
// new messages might have arrived, so keep looping
|
||||||
} while (getPendingMessages(store, pluginKey).length);
|
} while (getPendingMessages(store, pluginKey).length);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPendingMessages(
|
function getPendingMessages(
|
||||||
|
|||||||
Reference in New Issue
Block a user