Skip to content

Commit 5a1cd99

Browse files
authored
fix(sdk-metrics): Update default Histogram's boundary to match OTEL's spec (open-telemetry#3893)
1 parent 95a5e0c commit 5a1cd99

File tree

5 files changed

+42
-14
lines changed

5 files changed

+42
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
1313

1414
### :bug: (Bug Fix)
1515

16+
* fix(sdk-metrics): Update default Histogram's boundary to match OTEL's spec [#3893](https://github.com/open-telemetry/opentelemetry-js/pull/3893/) @chigia001
17+
1618
### :books: (Refine Doc)
1719

1820
### :house: (Internal)

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: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,11 @@ 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: [
301+
0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000,
302+
7500, 10000,
303+
],
304+
counts: [0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
302305
},
303306
count: 2,
304307
sum: 10,
@@ -310,8 +313,11 @@ describe('Instruments', () => {
310313
attributes: { foo: 'bar' },
311314
value: {
312315
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],
316+
boundaries: [
317+
0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000,
318+
7500, 10000,
319+
],
320+
counts: [0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
315321
},
316322
count: 2,
317323
sum: 100,
@@ -352,8 +358,11 @@ describe('Instruments', () => {
352358
attributes: {},
353359
value: {
354360
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],
361+
boundaries: [
362+
0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000,
363+
7500, 10000,
364+
],
365+
counts: [0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
357366
},
358367
count: 2,
359368
sum: 110,
@@ -379,8 +388,11 @@ describe('Instruments', () => {
379388
attributes: {},
380389
value: {
381390
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],
391+
boundaries: [
392+
0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000,
393+
7500, 10000,
394+
],
395+
counts: [0, 0, 0, 2, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
384396
},
385397
count: 4,
386398
sum: 220,
@@ -422,8 +434,11 @@ describe('Instruments', () => {
422434
attributes: {},
423435
value: {
424436
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],
437+
boundaries: [
438+
0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000,
439+
7500, 10000,
440+
],
441+
counts: [0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
427442
},
428443
count: 2,
429444
sum: 10.1,
@@ -435,8 +450,11 @@ describe('Instruments', () => {
435450
attributes: { foo: 'bar' },
436451
value: {
437452
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],
453+
boundaries: [
454+
0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000,
455+
7500, 10000,
456+
],
457+
counts: [0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
440458
},
441459
count: 2,
442460
sum: 100.1,

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ 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+
[
139+
0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500,
140+
10000,
141+
]
139142
);
140143
});
141144
});

0 commit comments

Comments
 (0)