Skip to content

Commit

Permalink
Add tasks_per_node retrieval stats. Closes #78
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Dec 14, 2023
1 parent 22af5c3 commit 140048d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/retrieval-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions test/retrieval-stats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 140048d

Please sign in to comment.