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-metrics] Support exemplars when using exponential histograms #5396

Merged

Conversation

CodeBlanch
Copy link
Member

@CodeBlanch CodeBlanch commented Feb 28, 2024

Changes

  • Adds support for exemplars when using exponential histograms.

  • Improves test coverage for the permutations of the MetricPoint.UpdateWithExemplar methods (double & long):

    image

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

@CodeBlanch CodeBlanch added pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package metrics Metrics signal related labels Feb 28, 2024
@CodeBlanch CodeBlanch requested a review from a team February 28, 2024 06:40
Copy link

codecov bot commented Feb 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.27%. Comparing base (6250307) to head (5f97f42).
Report is 102 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5396      +/-   ##
==========================================
+ Coverage   83.38%   84.27%   +0.88%     
==========================================
  Files         297      284      -13     
  Lines       12531    12080     -451     
==========================================
- Hits        10449    10180     -269     
+ Misses       2082     1900     -182     
Flag Coverage Δ
unittests ?
unittests-Solution-Experimental 84.27% <100.00%> (?)
unittests-Solution-Stable 84.34% <100.00%> (?)

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

Files Coverage Δ
src/OpenTelemetry/Metrics/MetricPoint.cs 91.71% <100.00%> (+23.24%) ⬆️

... and 52 files with indirect coverage changes

.SetExemplarFilter(new AlwaysOnExemplarFilter())
.AddView(i =>
{
if (i.Name.StartsWith("testGauge"))
Copy link
Member

Choose a reason for hiding this comment

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

i am not able to see the need for custom sized (3) for this instrument, and not others? Are we validating them separately?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. I removed the view from this test. Probably got there copy/pasting 🤣 Observables are an interesting case for exemplars. We only observe them during collect so there will only ever be at most 1 exemplar exported regardless of reservoir size. If user is doing TraceBasedExemplarFilter then they likely will never see an exemplar for observables because they are collected outside of all traces unless you go and force a trace in the observe callback which feels very strange. Might need to do something about that in SDK/spec?

Copy link
Member

Choose a reason for hiding this comment

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

yes. I want to see if spec would change the defaults, so that exemplars are opt-in. specifically, users must opt-in to exemplars for each instrument. (The key reasoning being - most users just need exemplar for one key instrument, typically the one measuring latency. The current model enables Exemplars for every instrument, including Observables as well, leading to wasted cpu/memory etc.)

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

LGTM

@utpilla
Copy link
Contributor

utpilla commented Feb 28, 2024

@CodeBlanch Do you want to update the OTLP Exporter as well to export exemplars for Exponential Histograms?

@CodeBlanch CodeBlanch merged commit 278e246 into open-telemetry:main Feb 28, 2024
37 checks passed
@CodeBlanch CodeBlanch deleted the sdk-exponentialhistogram-exemplars branch February 28, 2024 17:59
@CodeBlanch
Copy link
Member Author

@utpilla

Do you want to update the OTLP Exporter as well to export exemplars for Exponential Histograms?

Going to be my next PR!

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

Successfully merging this pull request may close these issues.

3 participants