diff --git a/desktop/app/src/dispatcher/tracking.tsx b/desktop/app/src/dispatcher/tracking.tsx index 678ad361a..6af7763da 100644 --- a/desktop/app/src/dispatcher/tracking.tsx +++ b/desktop/app/src/dispatcher/tracking.tsx @@ -149,7 +149,22 @@ export default (store: Store, logger: Logger) => { }), ); - logger.track('usage', 'plugin-stats', getPluginBackgroundStats()); + const bgStats = getPluginBackgroundStats(); + logger.track('usage', 'plugin-stats', { + cpuTime: bgStats.cpuTime, + bytesReceived: bgStats.bytesReceived, + }); + for (const key of Object.keys(bgStats.byPlugin)) { + const { + cpuTimeTotal: _a, + messageCountTotal: _b, + bytesReceivedTotal: _c, + ...dataWithoutTotal + } = bgStats.byPlugin[key]; + if (Object.values(dataWithoutTotal).some((v) => v > 0)) { + logger.track('usage', 'plugin-stats-plugin', dataWithoutTotal, key); + } + } resetPluginBackgroundStatsDelta(); if ( diff --git a/desktop/app/src/utils/messageQueue.tsx b/desktop/app/src/utils/messageQueue.tsx index d04e01e74..0ec940bb7 100644 --- a/desktop/app/src/utils/messageQueue.tsx +++ b/desktop/app/src/utils/messageQueue.tsx @@ -54,12 +54,15 @@ onBytesReceived((plugin: string, bytes: number) => { export function getPluginBackgroundStats(): { cpuTime: number; // amount of ms cpu used since the last stats (typically every minute) + bytesReceived: number; byPlugin: {[plugin: string]: StatEntry}; } { let cpuTime: number = 0; + let bytesReceived: number = 0; const byPlugin = Array.from(pluginBackgroundStats.entries()).reduce( (aggregated, [pluginName, data]) => { cpuTime += data.cpuTimeDelta; + bytesReceived += data.bytesReceivedDelta; aggregated[pluginName] = data; return aggregated; }, @@ -67,6 +70,7 @@ export function getPluginBackgroundStats(): { ); return { cpuTime, + bytesReceived, byPlugin, }; } @@ -140,7 +144,6 @@ function processMessage( }, message: {method: string; params?: any}, ): State { - const statName = `${plugin.id}.${message.method}`; const reducerStartTime = Date.now(); flipperRecorderAddEvent(pluginKey, message.method, message.params); try { @@ -149,7 +152,7 @@ function processMessage( message.method, message.params, ); - addBackgroundStat(statName, Date.now() - reducerStartTime); + addBackgroundStat(plugin.id, Date.now() - reducerStartTime); return newPluginState; } catch (e) { console.error(`Failed to process event for plugin ${plugin.id}`, e);