Skip to content

Commit bcdec2d

Browse files
committed
opentelemetry-test-utils: assert explicit bucket boundaries in histogram metrics
1 parent b85775c commit bcdec2d

File tree

1 file changed

+18
-2
lines changed
  • tests/opentelemetry-test-utils/src/opentelemetry/test

1 file changed

+18
-2
lines changed

tests/opentelemetry-test-utils/src/opentelemetry/test/test_base.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
from opentelemetry import metrics as metrics_api
2121
from opentelemetry import trace as trace_api
2222
from opentelemetry.sdk.metrics import MeterProvider
23+
from opentelemetry.sdk.metrics._internal.aggregation import (
24+
_DEFAULT_EXPLICIT_BUCKET_HISTOGRAM_AGGREGATION_BOUNDARIES,
25+
)
2326
from opentelemetry.sdk.metrics._internal.point import Metric
2427
from opentelemetry.sdk.metrics.export import (
2528
DataPointT,
@@ -204,6 +207,12 @@ def is_data_points_equal(
204207
):
205208
return False
206209

210+
if (
211+
expected_data_point.explicit_bounds
212+
!= data_point.explicit_bounds
213+
):
214+
return False
215+
207216
return (
208217
values_diff <= est_value_delta
209218
and expected_data_point.attributes == dict(data_point.attributes)
@@ -239,7 +248,12 @@ def create_number_data_point(value, attributes):
239248

240249
@staticmethod
241250
def create_histogram_data_point(
242-
sum_data_point, count, max_data_point, min_data_point, attributes
251+
sum_data_point,
252+
count,
253+
max_data_point,
254+
min_data_point,
255+
attributes,
256+
explicit_bounds=None,
243257
):
244258
return HistogramDataPoint(
245259
count=count,
@@ -250,7 +264,9 @@ def create_histogram_data_point(
250264
start_time_unix_nano=0,
251265
time_unix_nano=0,
252266
bucket_counts=[],
253-
explicit_bounds=[],
267+
explicit_bounds=explicit_bounds
268+
if explicit_bounds is not None
269+
else _DEFAULT_EXPLICIT_BUCKET_HISTOGRAM_AGGREGATION_BOUNDARIES,
254270
)
255271

256272

0 commit comments

Comments
 (0)