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

[SDK] Fix Observable Counters/UpDownCounters #2298

Merged
merged 5 commits into from
Sep 18, 2023

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented Sep 6, 2023

Fixes #2296

Changes

The default aggregation type was not handled properly for Observable Counter/UpDownCounter, and the issue was surfaced/evident out with non-zero initial measurement value. Have fixed the issue. Also we were missing the test for Observable UpDownCounter. Have added the test to catch this error.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@lalitb lalitb requested a review from a team September 6, 2023 23:52
@codecov
Copy link

codecov bot commented Sep 7, 2023

Codecov Report

Merging #2298 (19346ad) into main (049f7e8) will decrease coverage by 0.06%.
The diff coverage is 76.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2298      +/-   ##
==========================================
- Coverage   87.52%   87.45%   -0.06%     
==========================================
  Files         199      199              
  Lines        5981     5996      +15     
==========================================
+ Hits         5234     5243       +9     
- Misses        747      753       +6     
Files Changed Coverage
...etry/sdk/metrics/aggregation/default_aggregation.h 76.00%

@@ -159,7 +160,29 @@ class DefaultAggregation
new DoubleSumAggregation(nostd::get<SumPointData>(point_data)));
}
default:
return DefaultAggregation::CreateAggregation(instrument_descriptor, nullptr);
return nullptr; // won't reach here
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an assert here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, will look into this separately. Not a big fan of adding assert in telemetry sdk. But returning nullptr (even for unreachable code) is also not nice thing. Probaby we can return DropAggregation just to be cautious. Will create a issue to track this.

Copy link
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

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

Starting review, just a question for now.

Copy link
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix.

@lalitb lalitb merged commit 0563a71 into open-telemetry:main Sep 18, 2023
45 checks passed
@marcalff marcalff changed the title Fix Observable Counters/UpDownCounters [SDK] Fix Observable Counters/UpDownCounters Oct 11, 2023
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.

Observable Counters/UpDownCounters Report Incorrect Values
3 participants