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] Add experimental envvar for setting ExemplarFilter for histograms #5611

Merged

Conversation

CodeBlanch
Copy link
Member

@CodeBlanch CodeBlanch commented May 13, 2024

Relates to #2527

Changes

  • Adds an experimental envvar OTEL_DOTNET_EXPERIMENTAL_METRICS_EXEMPLAR_FILTER_HISTOGRAMS which can be used to set the default SDK ExemplarFilter for histogram metrics.

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 labels May 13, 2024
@CodeBlanch CodeBlanch requested a review from a team as a code owner May 13, 2024 22:26
@CodeBlanch CodeBlanch mentioned this pull request May 13, 2024
6 tasks
Copy link

codecov bot commented May 13, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 85.70%. Comparing base (6250307) to head (63b947e).
Report is 227 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5611      +/-   ##
==========================================
+ Coverage   83.38%   85.70%   +2.31%     
==========================================
  Files         297      254      -43     
  Lines       12531    11016    -1515     
==========================================
- Hits        10449     9441    -1008     
+ Misses       2082     1575     -507     
Flag Coverage Δ
unittests ?
unittests-Solution-Experimental 85.56% <90.00%> (?)
unittests-Solution-Stable 85.70% <90.00%> (?)

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

Files Coverage Δ
src/OpenTelemetry/Metrics/Metric.cs 98.31% <100.00%> (+1.79%) ⬆️
src/OpenTelemetry/Metrics/MetricReaderExt.cs 92.24% <100.00%> (+2.24%) ⬆️
src/OpenTelemetry/Metrics/MetricStreamIdentity.cs 87.50% <100.00%> (+0.83%) ⬆️
src/OpenTelemetry/Metrics/MeterProviderSdk.cs 93.44% <82.14%> (+5.59%) ⬆️

... and 111 files with indirect coverage changes

| Environment variable | Description | Notes |
| -------------------------- | -------------------------------------------------- |-------|
| `OTEL_METRICS_EXEMPLAR_FILTER` | Sets the default `ExemplarFilter` to use for all metrics. | Added in `1.9.0` |
| `OTEL_DOTNET_EXPERIMENTAL_METRICS_EXEMPLAR_FILTER_HISTOGRAMS` | Sets the default `ExemplarFilter` to use for histogram metrics. If not set than `OTEL_METRICS_EXEMPLAR_FILTER` also applies to histograms. | Experimental key (may be removed or changed in the future). Added in `1.9.0` |
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
| `OTEL_DOTNET_EXPERIMENTAL_METRICS_EXEMPLAR_FILTER_HISTOGRAMS` | Sets the default `ExemplarFilter` to use for histogram metrics. If not set than `OTEL_METRICS_EXEMPLAR_FILTER` also applies to histograms. | Experimental key (may be removed or changed in the future). Added in `1.9.0` |
| `OTEL_DOTNET_EXPERIMENTAL_METRICS_EXEMPLAR_FILTER_HISTOGRAMS` | Sets the default `ExemplarFilter` to use for histogram metrics. If not set, then `OTEL_METRICS_EXEMPLAR_FILTER` also applies to histograms. | Experimental key (may be removed or changed in the future). Added in `1.9.0` |

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed this a bit for @vishweshbankwar's comment above.

ExemplarFilterType? exemplarFilter;
if (!TryParseExemplarFilterFromConfigurationValue(configValue, out var exemplarFilter))
{
OpenTelemetrySdkEventSource.Log.MeterProviderSdkEvent($"Exemplar filter configuration was found but the value '{configValue}' is invalid and will be ignored.");
Copy link
Member

Choose a reason for hiding this comment

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

should we be showing string interpolation in our own logging.. though this is just startup only!

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.

left couple nits about using dedicated internal logs about which ExemplarFilter is finally enabled.

@CodeBlanch CodeBlanch merged commit 1e065cb into open-telemetry:main May 16, 2024
37 checks passed
@CodeBlanch CodeBlanch deleted the sdk-exemplarfilter-histograms branch May 16, 2024 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
metrics pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants