Skip to content

Commit 628f079

Browse files
committed
chore(sdk-metrics): update default Histogram's boundary to match OTEL's spec
Signed-off-by: Chi Ma <[email protected]>
1 parent 95a5e0c commit 628f079

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,12 @@ describe('PrometheusExporter', () => {
514514
`test_histogram_bucket{key1="attributeValue1",le="100"} 1 ${mockedHrTimeMs}`,
515515
`test_histogram_bucket{key1="attributeValue1",le="250"} 1 ${mockedHrTimeMs}`,
516516
`test_histogram_bucket{key1="attributeValue1",le="500"} 1 ${mockedHrTimeMs}`,
517+
`test_histogram_bucket{key1="attributeValue1",le="750"} 1 ${mockedHrTimeMs}`,
517518
`test_histogram_bucket{key1="attributeValue1",le="1000"} 1 ${mockedHrTimeMs}`,
519+
`test_histogram_bucket{key1="attributeValue1",le="2500"} 1 ${mockedHrTimeMs}`,
520+
`test_histogram_bucket{key1="attributeValue1",le="5000"} 1 ${mockedHrTimeMs}`,
521+
`test_histogram_bucket{key1="attributeValue1",le="7500"} 1 ${mockedHrTimeMs}`,
522+
`test_histogram_bucket{key1="attributeValue1",le="10000"} 1 ${mockedHrTimeMs}`,
518523
`test_histogram_bucket{key1="attributeValue1",le="+Inf"} 1 ${mockedHrTimeMs}`,
519524
'',
520525
]);

packages/sdk-metrics/src/view/Aggregation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class LastValueAggregation extends Aggregation {
107107
*/
108108
export class HistogramAggregation extends Aggregation {
109109
private static DEFAULT_INSTANCE = new HistogramAggregator(
110-
[0, 5, 10, 25, 50, 75, 100, 250, 500, 1000],
110+
[0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000],
111111
true
112112
);
113113
createAggregator(_instrument: InstrumentDescriptor) {

packages/sdk-metrics/test/Instruments.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ describe('Instruments', () => {
297297
attributes: {},
298298
value: {
299299
buckets: {
300-
boundaries: [0, 5, 10, 25, 50, 75, 100, 250, 500, 1000],
301-
counts: [0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0],
300+
boundaries: [0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000],
301+
counts: [0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
302302
},
303303
count: 2,
304304
sum: 10,
@@ -310,8 +310,8 @@ describe('Instruments', () => {
310310
attributes: { foo: 'bar' },
311311
value: {
312312
buckets: {
313-
boundaries: [0, 5, 10, 25, 50, 75, 100, 250, 500, 1000],
314-
counts: [0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0],
313+
boundaries: [0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000],
314+
counts: [0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
315315
},
316316
count: 2,
317317
sum: 100,
@@ -352,8 +352,8 @@ describe('Instruments', () => {
352352
attributes: {},
353353
value: {
354354
buckets: {
355-
boundaries: [0, 5, 10, 25, 50, 75, 100, 250, 500, 1000],
356-
counts: [0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0],
355+
boundaries: [0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000],
356+
counts: [0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
357357
},
358358
count: 2,
359359
sum: 110,
@@ -379,8 +379,8 @@ describe('Instruments', () => {
379379
attributes: {},
380380
value: {
381381
buckets: {
382-
boundaries: [0, 5, 10, 25, 50, 75, 100, 250, 500, 1000],
383-
counts: [0, 0, 0, 2, 0, 0, 1, 1, 0, 0, 0],
382+
boundaries: [0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000],
383+
counts: [0, 0, 0, 2, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
384384
},
385385
count: 4,
386386
sum: 220,
@@ -422,8 +422,8 @@ describe('Instruments', () => {
422422
attributes: {},
423423
value: {
424424
buckets: {
425-
boundaries: [0, 5, 10, 25, 50, 75, 100, 250, 500, 1000],
426-
counts: [0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0],
425+
boundaries: [0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000],
426+
counts: [0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
427427
},
428428
count: 2,
429429
sum: 10.1,
@@ -435,8 +435,8 @@ describe('Instruments', () => {
435435
attributes: { foo: 'bar' },
436436
value: {
437437
buckets: {
438-
boundaries: [0, 5, 10, 25, 50, 75, 100, 250, 500, 1000],
439-
counts: [0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0],
438+
boundaries: [0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000],
439+
counts: [0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
440440
},
441441
count: 2,
442442
sum: 100.1,

packages/sdk-metrics/test/view/Aggregation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ describe('HistogramAggregator', () => {
135135
assert(aggregator instanceof HistogramAggregator);
136136
assert.deepStrictEqual(
137137
aggregator['_boundaries'],
138-
[0, 5, 10, 25, 50, 75, 100, 250, 500, 1000]
138+
[0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000]
139139
);
140140
});
141141
});

0 commit comments

Comments
 (0)