Skip to content

Commit d839501

Browse files
fix(web): extend HTTP latency histogram buckets
1 parent 829ecb3 commit d839501

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

packages/web/src/httpMetrics.integration.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ describe('httpMetrics', () => {
5656
// The finish channel fires after the response is flushed to the client.
5757
await new Promise(resolve => setTimeout(resolve, 100));
5858

59-
const counts = countLines(await registry.metrics());
59+
const metrics = await registry.metrics();
60+
const counts = countLines(metrics);
6061

6162
expect(counts.some(line => line.includes('route="/api/health"'))).toBe(true);
6263
expect(counts.some(line => line.includes('status="200"'))).toBe(true);
@@ -66,6 +67,12 @@ describe('httpMetrics', () => {
6667
expect(browse).toHaveLength(1);
6768
expect(browse[0].trim().endsWith('2')).toBe(true);
6869

70+
// Keep enough resolution to distinguish the long-tail stalls this
71+
// metric is intended to expose rather than collapsing them into +Inf.
72+
for (const upperBound of [15, 20, 30, 60]) {
73+
expect(metrics).toContain(`le="${upperBound}"`);
74+
}
75+
6976
// The scrape of the metrics port must not be recorded. Asserted on the
7077
// total observation count rather than on the absence of a `/metrics`
7178
// label: `/metrics` is not a known route, so it would land in `other`

packages/web/src/promClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const httpRequestDuration = new Histogram({
77
name: 'http_request_duration_seconds',
88
help: 'Duration of HTTP requests handled by the web server, in seconds',
99
labelNames: ['method', 'route', 'status'],
10-
buckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],
10+
buckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 15, 20, 30, 60],
1111
});
1212
registry.registerMetric(httpRequestDuration);
1313

0 commit comments

Comments
 (0)