Skip to content
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 @@ -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))
- Fix `BatchLogRecordProcessor` default `schedule_delay_millis` from 5000ms to 1000ms to comply with the OTel specification. Note: logs may be exported 5x more frequently by default (e.g. for users who don't explicitly set the `OTEL_BLRP_SCHEDULE_DELAY` env var).
([#4998](https://github.com/open-telemetry/opentelemetry-python/pull/4998))
- `opentelemetry-sdk`: Add `process` resource detector support to declarative file configuration via `detection_development.detectors[].process`
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