Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- `opentelemetry-sdk`: Fix `AttributeError` in `ExplicitBucketHistogramAggregation` when applied to non-Histogram instruments without explicit boundaries
([#5034](https://github.com/open-telemetry/opentelemetry-python/pull/5034))
- `opentelemetry-sdk`: Add shared `_parse_headers` helper for declarative config OTLP exporters
([#5021](https://github.com/open-telemetry/opentelemetry-python/pull/5021))
- `opentelemetry-api`: Replace a broad exception in attribute cleaning tests to satisfy pylint in the `lint-opentelemetry-api` CI job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,13 @@ def _create_aggregation(
if self._boundaries is not None:
boundaries = self._boundaries
else:
boundaries = instrument._advisory.explicit_bucket_boundaries
# guard for usage with instruments without advisory
advisory = getattr(instrument, "_advisory", None)
Comment thread
xrmx marked this conversation as resolved.
boundaries = (
advisory.explicit_bucket_boundaries
if advisory is not None
else None
)

return _ExplicitBucketHistogramAggregation(
attributes,
Expand Down
13 changes: 13 additions & 0 deletions opentelemetry-sdk/tests/metrics/test_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,19 @@ def test_boundaries(self):
),
)

def test_create_aggregation_on_instrument_without_boundaries(self):
"""ExplicitBucketHistogramAggregation should not crash when applied
to a non-Histogram instrument without explicit boundaries.
"""
aggregation = ExplicitBucketHistogramAggregation()
result = aggregation._create_aggregation(
_Counter("test.counter", Mock(), Mock()),
Mock(),
_default_reservoir_factory,
0,
)
self.assertIsInstance(result, _ExplicitBucketHistogramAggregation)


class TestAggregationFactory(TestCase):
def test_sum_factory(self):
Expand Down
Loading