Repository navigation
Conversation
Validate explicit bucket boundaries early at initialization time in ExplicitBucketHistogramAggregation instead of deferring to runtime measurement collection. If advised boundaries on an instrument are invalid, safely log a warning and fall back to default boundaries. Fixes open-telemetry#5951
|
Pull request dashboard statusClosed · refreshed 2026-11-25 18:14 UTC Status above doesn't look right?
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which problem is this PR solving?
Fixes #5951
When configuring an
ExplicitBucketHistogramAggregationin aViewwith invalid boundaries (such as unsorted numbers[100.0, 10.0, 50.0], duplicate numbers[1.0, 1.0], or non-finite values[float("nan")]),ExplicitBucketHistogramAggregation.__init__accepted the boundaries without validation. The validation was deferred to internal_ExplicitBucketHistogramAggregation.__init__during measurement recording (histogram.record(...)), raising an uncaughtValueError: boundaries must be strictly increasingand crashing host applications at runtime.Per the OpenTelemetry Error Handling Specification:
Short description of the changes
_validate_boundariestoExplicitBucketHistogramAggregation.__init__so invalid boundaries are caught and rejected immediately at instantiation time._explicit_bucket_boundaries_from_advisory, validate advised boundaries before returning them; if invalid, log a warning and fall back to default boundaries (_DEFAULT_EXPLICIT_BUCKET_HISTOGRAM_AGGREGATION_BOUNDARIES) so runtime operations never crash.tests/metrics/test_aggregation.pyverifying that invalid boundaries passed toExplicitBucketHistogramAggregationraiseValueError.tests/metrics/integration_test/test_histogram_advisory_explicit_buckets.pyverifying that invalid boundaries from an instrument advisory safely fall back to default boundaries with a logged warning.Type of change