Skip to content

fix(sdk-metrics-base): only record non-negative histogram values.#3002

Merged
vmarchaud merged 5 commits intoopen-telemetry:mainfrom
dynatrace-oss-contrib:fix-non-negative-histogram-values
May 30, 2022
Merged

fix(sdk-metrics-base): only record non-negative histogram values.#3002
vmarchaud merged 5 commits intoopen-telemetry:mainfrom
dynatrace-oss-contrib:fix-non-negative-histogram-values

Conversation

@pichlermarc
Copy link
Member

Which problem is this PR solving?

Currently, Histograms allow for negative values to be recorded. However, the spec states this for parameters of the Histogram record() function:

Parameters:

  • The amount of the Measurement, which MUST be a non-negative numeric value.
  • Optional attributes.

This PR changes the Histogram Implementation to drop negative values and to log when they are passed to record(). This behavior is in line with the Python and Java SDK implementations.

Fixes #3001

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Adapted existing Unit Tests
  • Added Unit Tests

Checklist:

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

@codecov
Copy link

codecov bot commented May 30, 2022

Codecov Report

Merging #3002 (eb1f0a9) into main (fd95d42) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #3002   +/-   ##
=======================================
  Coverage   92.77%   92.78%           
=======================================
  Files         183      183           
  Lines        6134     6137    +3     
  Branches     1300     1301    +1     
=======================================
+ Hits         5691     5694    +3     
  Misses        443      443           
Impacted Files Coverage Δ
.../opentelemetry-sdk-metrics-base/src/Instruments.ts 94.59% <100.00%> (+0.47%) ⬆️

@pichlermarc pichlermarc marked this pull request as ready for review May 30, 2022 14:05
@pichlermarc pichlermarc requested a review from a team May 30, 2022 14:05
@vmarchaud vmarchaud merged commit fcef5e2 into open-telemetry:main May 30, 2022
@pichlermarc pichlermarc deleted the fix-non-negative-histogram-values branch May 31, 2022 09:03
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.

Histograms should not allow negative values to be recorded

3 participants