Skip to content

Commit bfc3582

Browse files
authored
fix: percentile metrics (#837)
1 parent f3901ef commit bfc3582

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

src/internal/monitoring/otel-metrics.ts

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -104,47 +104,44 @@ if (otelMetricsEnabled) {
104104
readers.push(prometheusExporter)
105105

106106
// Bucket boundaries for duration histograms (in seconds)
107-
// Provides good resolution from 1ms to 10s
108-
const durationBuckets = [0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10]
107+
// Provides good resolution from 0.5ms to 10s
108+
const durationBuckets = [
109+
0.0005, 0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10,
110+
]
111+
112+
const histogramAggregation = {
113+
type: AggregationType.EXPLICIT_BUCKET_HISTOGRAM,
114+
options: { boundaries: durationBuckets },
115+
} as const
109116

110117
const meterProvider = new MeterProvider({
111118
resource,
112119
readers,
113120
views: [
114121
{
115-
instrumentName: 'storage_api_http_request_duration_seconds',
116-
aggregation: {
117-
type: AggregationType.EXPLICIT_BUCKET_HISTOGRAM,
118-
options: { boundaries: durationBuckets },
119-
},
122+
meterName: 'storage-api',
123+
instrumentName: 'http_request_duration_seconds',
124+
aggregation: histogramAggregation,
120125
},
121126
{
122-
instrumentName: 'storage_api_database_query_performance_seconds',
123-
aggregation: {
124-
type: AggregationType.EXPLICIT_BUCKET_HISTOGRAM,
125-
options: { boundaries: durationBuckets },
126-
},
127+
meterName: 'storage-api',
128+
instrumentName: 'database_query_performance_seconds',
129+
aggregation: histogramAggregation,
127130
},
128131
{
129-
instrumentName: 'storage_api_queue_job_scheduled_time_seconds',
130-
aggregation: {
131-
type: AggregationType.EXPLICIT_BUCKET_HISTOGRAM,
132-
options: { boundaries: durationBuckets },
133-
},
132+
meterName: 'storage-api',
133+
instrumentName: 'queue_job_scheduled_time_seconds',
134+
aggregation: histogramAggregation,
134135
},
135136
{
136-
instrumentName: 'storage_api_s3_upload_part_seconds',
137-
aggregation: {
138-
type: AggregationType.EXPLICIT_BUCKET_HISTOGRAM,
139-
options: { boundaries: durationBuckets },
140-
},
137+
meterName: 'storage-api',
138+
instrumentName: 's3_upload_part_seconds',
139+
aggregation: histogramAggregation,
141140
},
142141
{
143-
instrumentName: 'storage_api_db_connection_acquire_seconds',
144-
aggregation: {
145-
type: AggregationType.EXPLICIT_BUCKET_HISTOGRAM,
146-
options: { boundaries: durationBuckets },
147-
},
142+
meterName: 'storage-api',
143+
instrumentName: 'db_connection_acquire_seconds',
144+
aggregation: histogramAggregation,
148145
},
149146
],
150147
})

0 commit comments

Comments
 (0)