Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: metric for successful http retrievals #437

Merged
merged 7 commits into from
Jan 8, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions test/retrieval-stats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ describe('retrieval statistics', () => {
/** @type {Measurement[]} */
const measurements = [
{
...VALID_MEASUREMENT,
protocol: 'http'
...VALID_MEASUREMENT
},
{
...VALID_MEASUREMENT,
Expand All @@ -32,8 +31,7 @@ describe('retrieval statistics', () => {
first_byte_at: new Date('2023-11-01T09:00:10.000Z').getTime(),
end_at: new Date('2023-11-01T09:00:50.000Z').getTime(),
finished_at: new Date('2023-11-01T09:00:30.000Z').getTime(),
byte_length: 2048,
protocol: 'http'
byte_length: 2048
},
{
...VALID_MEASUREMENT,
Expand All @@ -58,9 +56,8 @@ describe('retrieval statistics', () => {

// invalid task
cid: 'bafyinvalid',
provider_address: '/dns4/production-ipfs-peer.pinata.cloud/tcp/3000/ws/p2p/Qma8ddFEQWEU8ijWvdxXm3nxU7oHsRtCykAaVz8WUYhiKn',
provider_address: '/dns4/production-ipfs-peer.pinata.cloud/tcp/3000/ws/p2p/Qma8ddFEQWEU8ijWvdxXm3nxU7oHsRtCykAaVz8WUYhiKn'
// Check that the task is ignored if the retrieval result is not OK
protocol: 'http'
}
]

Expand All @@ -71,7 +68,6 @@ describe('retrieval statistics', () => {
assertPointFieldValue(point, 'measurements', '4i')
assertPointFieldValue(point, 'unique_tasks', '3i')
assertPointFieldValue(point, 'success_rate', '0.25')
assertPointFieldValue(point, 'success_rate_http', '0.25')
assertPointFieldValue(point, 'participants', '2i')
assertPointFieldValue(point, 'participants', '2i')
assertPointFieldValue(point, 'inet_groups', '2i')
Expand Down Expand Up @@ -213,6 +209,39 @@ describe('retrieval statistics', () => {
assertPointFieldValue(point, 'nano_score_per_inet_group_p50', '333333333i' /* =2/6 */)
assertPointFieldValue(point, 'nano_score_per_inet_group_max', '500000000i' /* =3/6 */)
})

it('records successful http rate', async () => {
/** @type {Measurement[]} */
const measurements = [
{
// Standard measurement, no http protocol used
...VALID_MEASUREMENT
NikolasHaimerl marked this conversation as resolved.
Show resolved Hide resolved
},
{
// A successful http measurement
...VALID_MEASUREMENT,
protocol: 'http'
},
{
...VALID_MEASUREMENT,
retrievalResult: 'HTTP_500'
NikolasHaimerl marked this conversation as resolved.
Show resolved Hide resolved
},
{
...VALID_MEASUREMENT,
// Should not be picked up, as the retrieval timed out
retrievalResult: 'TIMEOUT',
protocol: 'http'
}
]

const point = new Point('stats')
buildRetrievalStats(measurements, point)
debug('stats', point.fields)

assertPointFieldValue(point, 'success_rate', '0.5')
// Only one of the successful measurements used http
assertPointFieldValue(point, 'success_rate_http', '0.25')
})
})

describe('getValueAtPercentile', () => {
Expand Down
Loading