feat: Allow configuring of min/max in histograms#8095
feat: Allow configuring of min/max in histograms#8095MikeGoldsmith wants to merge 16 commits intoopen-telemetry:mainfrom
Conversation
Supports disabling min/max recording to work around GCP min/max handling issues. Backward compatible - defaults to true.
Verifies min/max not tracked when disabled.
9caaa69 to
8f364a5
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8095 +/- ##
============================================
- Coverage 90.34% 90.31% -0.03%
- Complexity 7646 7650 +4
============================================
Files 841 843 +2
Lines 23002 23055 +53
Branches 2293 2307 +14
============================================
+ Hits 20781 20823 +42
- Misses 1508 1516 +8
- Partials 713 716 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jack-berg
left a comment
There was a problem hiding this comment.
Couple small comments, but looks good overall. Thanks!
sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/Aggregation.java
Outdated
Show resolved
Hide resolved
...main/java/io/opentelemetry/sdk/metrics/internal/view/ExplicitBucketHistogramAggregation.java
Outdated
Show resolved
Hide resolved
...o/opentelemetry/sdk/metrics/internal/aggregator/DoubleExplicitBucketHistogramAggregator.java
Show resolved
Hide resolved
...o/opentelemetry/sdk/metrics/internal/aggregator/DoubleExplicitBucketHistogramAggregator.java
Outdated
Show resolved
Hide resolved
…nto mike/disable-histogram-minmax
- Remove @SInCE annotations (added during release flow) - Remove old create() overloads without recordMinMax, update callers - Remove redundant // read-only comment on final primitive field Claude claude-sonnet-4-6 assisted with this change.
a681c40 to
849cc50
Compare
...rc/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AggregationFactoryTest.java
Outdated
Show resolved
Hide resolved
Declarative config tests compare aggregation equality via toString(), so recordMinMax must be included for the comparisons to be valid. Claude claude-sonnet-4-6 assisted with this change.
jack-berg
left a comment
There was a problem hiding this comment.
Will leave open for a few days to see if any other @open-telemetry/java-approvers have feedback about the new public API surface area
I finally got a chance to look at this. I'm slightly concerned about adding a simple boolean option to this. If we end up with more of them in the future, the API surface could end up exploding in non-optimal ways. What would y'all think about creating an AggregationOptions type that would encapsulate this new option, and also provide a place to put future options, when/if they crop up? |
Thought more on this, and I'm not sure. Other existing Histogram options (maxBuckets, maxScale, and bucketBoundaries) all use the same in-line design. Adding an Options class just for recordMinMax feels excessive, especially if we don't know of any other options that might come along? @jkwatson is this something you feel strongly about adding? |
…nto mike/disable-histogram-minmax
Maybe we should put all the current options into an HistogramAggregationOptions as well, rather than continue the sub-optimal combinatoric parameter approach? |
Sure, I could look at doing that. |
Replace boolean recordMinMax params on Aggregation factory methods with a HistogramOptions builder, providing a single extensible place for future histogram options without requiring new method overloads. Claude claude-sonnet-4-6 assisted with this change.
|
@jkwatson I've updated to use an options builder for the cc @jack-berg as the implementation has changed a bit since your approval |
sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/HistogramOptions.java
Outdated
Show resolved
Hide resolved
sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/HistogramOptions.java
Outdated
Show resolved
Hide resolved
Claude claude-sonnet-4-6 assisted with this change.
…ns builders Replaces HistogramOptions with per-type options builders that include all histogram parameters (boundaries/scale/maxBuckets + recordMinMax). Deprecates positional-param overloads which now delegate to the options-based methods. Assisted-by: Claude Sonnet 4.6
…nto mike/disable-histogram-minmax
| * | ||
| * @see Aggregation#explicitBucketHistogram(ExplicitBucketHistogramOptions) | ||
| */ | ||
| public final class ExplicitBucketHistogramOptions { |
There was a problem hiding this comment.
I think we should model these after SpanLimits, LogLimits, RetryPolicy. Differences:
- AutoValue for the record class and the builder
- "get" prefix for accessors, i.e. "getBucketBoundaries" rather than "bucketBoundaries"
Benefits are mostly just consistency, but we do get hashCode and equals implementations for free.
There was a problem hiding this comment.
I agree. Consistency is pretty important. Sorry for all the thrash, @MikeGoldsmith , but getting these APIs right is super important, as we can never change them once they are in and stable.
There was a problem hiding this comment.
Yeah, that's fine - I want them to be correct too 👍🏻
There was a problem hiding this comment.
I updated the options builders to match what I found in the other options classes (spanlimits, loglimits, retrypolicy) in 78e2805.
Let me know what you both both think 😄
- Use AutoValue + @AutoValue.Builder for ExplicitBucketHistogramOptions and Base2ExponentialHistogramOptions, providing generated hashCode/equals - Rename accessors to use get* prefix (getBucketBoundaries, getRecordMinMax, getMaxBuckets, getMaxScale) for consistency with other SDK config types - Add getDefault() and toBuilder() to both options types - Move maxBuckets/maxScale validation into Base2ExponentialHistogramOptions Builder.build() using the autoBuild() pattern, removing it from the internal aggregation class Assisted-by: Claude Sonnet 4.6 Made-with: Cursor
…nto mike/disable-histogram-minmax
Update to use Base2ExponentialHistogramOptions builder instead of the deprecated base2ExponentialBucketHistogram(int, int) positional overload. Made-with: Cursor
|
FYI we had a test failure in |
Summary
Adds support for disabling min/max recording in histogram aggregations per the OpenTelemetry spec.
Fixes #7859
Motivation
Some users need the ability to disable min/max recording in histograms. The OpenTelemetry spec requires this parameter for both explicit and exponential histogram aggregations.
Changes
HistogramOptionsbuilder to encapsulate histogram behavioral options (currentlyrecordMinMax), providing an extensible place for future options without method overload explosionAggregation.explicitBucketHistogram(List<Double>, HistogramOptions)andAggregation.base2ExponentialBucketHistogram(int, int, HistogramOptions)record_min_maxfrom YAML to SDKHistogramOptionsdefault torecordMinMax=trueTesting
DoubleExplicitBucketHistogramAggregatorTest.testRecordMinMaxDisabled— verifies min/max not tracked when disabled for explicit histogramsDoubleBase2ExponentialHistogramAggregatorTest.testRecordMinMaxDisabled— verifies min/max not tracked when disabled for exponential histograms