Skip to content

Conversation

hannahhaering
Copy link
Contributor

@hannahhaering hannahhaering commented Oct 2, 2025

Fixes #5635

Changes

Reset scale to 20 of the Base2 Exponential Bucket Histogram after each collection cycle when using delta aggregation temporality.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@hannahhaering hannahhaering marked this pull request as ready for review October 2, 2025 02:35
@hannahhaering hannahhaering requested a review from a team as a code owner October 2, 2025 02:35
@github-actions github-actions bot added the pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package label Oct 2, 2025
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.65%. Comparing base (0ea6c23) to head (bc0d165).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6557      +/-   ##
==========================================
- Coverage   86.67%   86.65%   -0.02%     
==========================================
  Files         258      258              
  Lines       11895    11896       +1     
==========================================
- Hits        10310    10309       -1     
- Misses       1585     1587       +2     
Flag Coverage Δ
unittests-Project-Experimental 86.55% <100.00%> (-0.04%) ⬇️
unittests-Project-Stable 86.55% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ics/MetricPoint/Base2ExponentialBucketHistogram.cs 100.00% <100.00%> (ø)
...c/OpenTelemetry/Metrics/MetricPoint/MetricPoint.cs 94.17% <100.00%> (-0.07%) ⬇️

... and 3 files with indirect coverage changes

Copy link
Member

@martincostello martincostello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me. Please update the CHANGELOG.

this.runningValue.AsLong = 0;
histogram.RunningSum = 0;
histogram.Reset();
histogram.Reset(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These callsites would be more readable with a named-parameter:

Suggested change
histogram.Reset(false);
histogram.Reset(isMinMax: false);

histogram.Reset();
histogram.RunningMin = double.PositiveInfinity;
histogram.RunningMax = double.NegativeInfinity;
histogram.Reset(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
histogram.Reset(true);
histogram.Reset(isMinMax: true);

else
{
expectedHistogram.Reset();
expectedHistogram.Reset(aggregationType == AggregationType.HistogramWithMinMax);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expectedHistogram.Reset(aggregationType == AggregationType.HistogramWithMinMax);
expectedHistogram.Reset(isMinMax: aggregationType == AggregationType.HistogramWithMinMax);

AssertExponentialBucketsAreCorrect(expectedHistogram, metricPoint.GetExponentialHistogramData());
Assert.Equal(50, sum);
Assert.Equal(6, count);
Assert.True(firstScale <= Metric.DefaultExponentialHistogramMaxScale);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or some alternate message. We want more meaningful output in the logs if the test fails than "Expected true but got false".

Suggested change
Assert.True(firstScale <= Metric.DefaultExponentialHistogramMaxScale);
Assert.True(firstScale <= Metric.DefaultExponentialHistogramMaxScale, "The first scale value, {0}, is greater than Metric.DefaultExponentialHistogramMaxScale.", firstScale);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Base2 Exponential Bucket Histogram should reset to scale 20 after each collection cycle if DELTA aggregation temporality is used
3 participants