Skip to content

opentelemetry-test-utils: assert explicit bucket boundaries in histogram metrics #4595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#4333](https://github.com/open-telemetry/opentelemetry-python/pull/4333))
- opentelemetry-api: allow importlib-metadata 8.7.0
([#4593](https://github.com/open-telemetry/opentelemetry-python/pull/4593))
- opentelemetry-test-utils: assert explicit bucket boundaries in histogram metrics
([#4595](https://github.com/open-telemetry/opentelemetry-python/pull/4595))

## Version 1.33.0/0.54b0 (2025-05-09)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
from opentelemetry import metrics as metrics_api
from opentelemetry import trace as trace_api
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics._internal.aggregation import (
_DEFAULT_EXPLICIT_BUCKET_HISTOGRAM_AGGREGATION_BOUNDARIES,
)
from opentelemetry.sdk.metrics._internal.point import Metric
from opentelemetry.sdk.metrics.export import (
DataPointT,
Expand Down Expand Up @@ -204,6 +207,12 @@ def is_data_points_equal(
):
return False

if (
expected_data_point.explicit_bounds
!= data_point.explicit_bounds
):
return False

return (
values_diff <= est_value_delta
and expected_data_point.attributes == dict(data_point.attributes)
Expand Down Expand Up @@ -239,7 +248,12 @@ def create_number_data_point(value, attributes):

@staticmethod
def create_histogram_data_point(
sum_data_point, count, max_data_point, min_data_point, attributes
sum_data_point,
count,
max_data_point,
min_data_point,
attributes,
explicit_bounds=None,
):
return HistogramDataPoint(
count=count,
Expand All @@ -250,7 +264,9 @@ def create_histogram_data_point(
start_time_unix_nano=0,
time_unix_nano=0,
bucket_counts=[],
explicit_bounds=[],
explicit_bounds=explicit_bounds
if explicit_bounds is not None
else _DEFAULT_EXPLICIT_BUCKET_HISTOGRAM_AGGREGATION_BOUNDARIES,
)


Expand Down