Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(histogram): fix maximum when only values < -1 are provided #3086

Conversation

pichlermarc
Copy link
Member

Which problem is this PR solving?

HistogramAggregator incorrectly assumes positive-only values, and therefore produces wrong max values on export when only negative values are provided (e.g. when ExplicitBucketHistogramAggregation is used with UpDownCounter via View configuration).

This PR fixes this by replacing the default max with -Infinity

Fixes #3085

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Added unit test.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@codecov
Copy link

codecov bot commented Jul 11, 2022

Codecov Report

Merging #3086 (28d8c56) into main (747c404) will decrease coverage by 0.41%.
The diff coverage is 100.00%.

❗ Current head 28d8c56 differs from pull request most recent head fc430be. Consider uploading reports for the commit fc430be to get more accurate results

@@            Coverage Diff             @@
##             main    #3086      +/-   ##
==========================================
- Coverage   93.08%   92.66%   -0.42%     
==========================================
  Files         188      173      -15     
  Lines        6261     5523     -738     
  Branches     1323     1175     -148     
==========================================
- Hits         5828     5118     -710     
+ Misses        433      405      -28     
Impacted Files Coverage Δ
...metry-sdk-metrics-base/src/aggregator/Histogram.ts 91.04% <100.00%> (ø)
packages/opentelemetry-resources/karma.worker.js 0.00% <0.00%> (-100.00%) ⬇️
...kages/opentelemetry-sdk-trace-base/karma.worker.js 0.00% <0.00%> (-100.00%) ⬇️
...lemetry-resources/src/detectors/BrowserDetector.ts 53.33% <0.00%> (-46.67%) ⬇️
...lemetry-resources/src/detectors/ProcessDetector.ts 95.45% <0.00%> (-4.55%) ⬇️
packages/opentelemetry-sdk-trace-web/src/utils.ts
...-sdk-trace-web/src/enums/PerformanceTimingNames.ts
...-instrumentation-fetch/src/enums/AttributeNames.ts
...es/opentelemetry-context-zone-peer-dep/src/util.ts
...ation-xml-http-request/src/enums/AttributeNames.ts
... and 10 more

Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

Thanks for the update. I think at one point the spec had positive only values so this is likely a remnant of that? Not sure. In any case it is a good change.

@dyladan dyladan added this to the Metrics GA milestone Jul 11, 2022
@pichlermarc
Copy link
Member Author

Thanks for the update. I think at one point the spec had positive only values so this is likely a remnant of that? Not sure. In any case it is a good change.

When I recently implemented this feature in #3032, I was not thinking of Histogram Aggregations in combination with UpDownCounter and ObservableGauge, which allow negative values. 😓 For Histogram instruments, we check if all values are non-negative (as per the spec). I did not consider that the aggregation might be used by non-histograms, and that the values provided there can be < -1.

@dyladan dyladan removed this from the Metrics GA milestone Jul 13, 2022
@vmarchaud vmarchaud merged commit db32860 into open-telemetry:main Jul 15, 2022
@pichlermarc pichlermarc deleted the bugfix/max-on-negative-values branch July 20, 2022 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Histogram Aggregation on Up-Down-Counters results in wrong max
4 participants