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

[service] Add service::telemetry::metrics::views config key #12433

Merged
merged 9 commits into from
Mar 28, 2025

Conversation

jade-guiton-dd
Copy link
Contributor

@jade-guiton-dd jade-guiton-dd commented Feb 19, 2025

Description

This PR adds a service::telemetry::metrics::views config key, which explicitly sets the list of metric views used for internal telemetry, mirroring meter_provider::views in the SDK config. This can be used to disable specific internal metrics, among other uses.

This key will cause an error if used alongside other features which would normally implicitly create views, such as:

  • not setting service::telemetry::metrics::level to detailed;
  • enabling the telemetry.disableHighCardinalityMetrics feature gate.

Further discussion needed

  • A comment notes that the telemetry.disableHighCardinalityMetrics alpha gate "will be removed when the collector allows for view configuration". I think setting the gate as deprecated first would be the correct thing to do, but it means that users relying on it will see their Collectors crash on update. Is that okay?

  • In the context of being able to enable/disable specific metrics, this key is only useful to disable metrics from an "all enabled" baseline. It cannot easily be used to customize the set of metrics emitted at level: normal, level: basic. Discussion is ongoing in Own-telemetry: Ability to enabled/disable individual metrics #10769 on how to handle that, but the solution will probably involve a new key, which should hopefully be backward-compatible with the user-visible changes in this PR.

Link to tracking issue

Updates #10769

Testing

None yet

Documentation

None yet, except the changelog

Copy link

codecov bot commented Feb 19, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 8 lines in your changes missing coverage. Please review.

Project coverage is 91.52%. Comparing base (0654ae5) to head (45eda44).
Report is 29 commits behind head on main.

Files with missing lines Patch % Lines
service/service.go 78.26% 4 Missing and 1 partial ⚠️
service/telemetry/config.go 0.00% 2 Missing and 1 partial ⚠️

❌ Your patch status has failed because the patch coverage (80.00%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12433      +/-   ##
==========================================
- Coverage   91.53%   91.52%   -0.02%     
==========================================
  Files         483      479       -4     
  Lines       26433    26486      +53     
==========================================
+ Hits        24196    24240      +44     
+ Misses       1772     1770       -2     
- Partials      465      476      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

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

Can you increase the test coverage? Could you also add information about this (in a draft PR) to opentelemetry.io docs?

@jade-guiton-dd
Copy link
Contributor Author

jade-guiton-dd commented Feb 20, 2025

Regarding the lack of test coverage: it's almost entirely from the existing code for the feature gate that I just moved. I can try to add a new test for it; is there a way to set feature gates in tests?

@mx-psi
Copy link
Member

mx-psi commented Feb 20, 2025

Regarding the lack of test coverage: it's almost entirely from the existing code for the feature gate that I just moved. I can try to add a new test for it; is there a way to set feature gates in tests?

You can check the tests that are modified in #12377

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Mar 20, 2025
@mx-psi mx-psi removed the Stale label Mar 20, 2025
@mx-psi mx-psi requested a review from bogdandrutu March 24, 2025 11:07
Comment on lines 75 to 80
Readers []config.MetricReader `mapstructure:"readers"`

// Views allows advanced configuration of emitted metrics by setting
// the list of views passed to the SDK.
// This is incompatible with `level` values other than `detailed`.
Views []config.View `mapstructure:"views"`
Copy link
Member

Choose a reason for hiding this comment

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

instead, use:

MeterProvider MeterProvider `mapstructure:",squash"`

This will show that we use everything from the config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I modified the SDK instantiation code to pass the modified original struct to otelconf instead of creating a new one, in case new fields get added later upstream.

@mx-psi mx-psi added this pull request to the merge queue Mar 28, 2025
Merged via the queue into open-telemetry:main with commit 8a79193 Mar 28, 2025
52 of 56 checks passed
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.

4 participants