From 140048df5e755beb4490ffb9d2b17c79c6a8c969 Mon Sep 17 00:00:00 2001 From: Julian Gruber Date: Thu, 14 Dec 2023 12:26:07 +0100 Subject: [PATCH] Add `tasks_per_node` retrieval stats. Closes #78 --- lib/retrieval-stats.js | 9 +++++++++ test/retrieval-stats.test.js | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/lib/retrieval-stats.js b/lib/retrieval-stats.js index 50a8d00f..7d387cca 100644 --- a/lib/retrieval-stats.js +++ b/lib/retrieval-stats.js @@ -33,6 +33,7 @@ export const buildRetrievalStats = (measurements, telemetryPoint) => { const participants = new Set() const inetGroups = new Set() + const tasksPerNode = new Map() let downloadBandwidth = 0 const ttfbValues = [] @@ -67,6 +68,9 @@ export const buildRetrievalStats = (measurements, telemetryPoint) => { } if (ttfb !== undefined && ttfb > 0 && m.status_code === 200) ttfbValues.push(ttfb) if (duration !== undefined && duration > 0) durationValues.push(duration) + + const node = `${m.inet_group}::${m.participantAddress}` + tasksPerNode.set(node, (tasksPerNode.get(node) ?? 0) + 1) } const successRate = resultBreakdown.OK / totalCount @@ -80,6 +84,11 @@ export const buildRetrievalStats = (measurements, telemetryPoint) => { addHistogramToPoint(telemetryPoint, ttfbValues, 'ttfb_') addHistogramToPoint(telemetryPoint, durationValues, 'duration_') addHistogramToPoint(telemetryPoint, sizeValues, 'car_size_') + addHistogramToPoint( + telemetryPoint, + Array.from(tasksPerNode.values()), + 'tasks_per_node_' + ) for (const [result, count] of Object.entries(resultBreakdown)) { telemetryPoint.floatField(`result_rate_${result}`, count / totalCount) diff --git a/test/retrieval-stats.test.js b/test/retrieval-stats.test.js index cad343ba..18860ffc 100644 --- a/test/retrieval-stats.test.js +++ b/test/retrieval-stats.test.js @@ -82,6 +82,10 @@ describe('retrieval statistics', () => { assertPointFieldValue(point, 'car_size_mean', '69906090i') assertPointFieldValue(point, 'car_size_p90', '167772569i') assertPointFieldValue(point, 'car_size_max', '209715200i') + + assertPointFieldValue(point, 'tasks_per_node_p5', '1i') + assertPointFieldValue(point, 'tasks_per_node_p50', '2i') + assertPointFieldValue(point, 'tasks_per_node_p95', '2i') }) it('handles first_byte_at set to unix epoch', () => {