Skip to content

[Metrics] Exclude list for tags on Metrics#7373

Merged
martincostello merged 29 commits into
open-telemetry:mainfrom
nabutabu:exclude-tags-1
Jul 14, 2026
Merged

[Metrics] Exclude list for tags on Metrics#7373
martincostello merged 29 commits into
open-telemetry:mainfrom
nabutabu:exclude-tags-1

Conversation

@nabutabu

@nabutabu nabutabu commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #4427
Design discussion issue open-telemetry/opentelemetry-specification#4188

Changes

Adds an exclude list to MetricStreamConfiguration and FindMetricAggregatorsExcludeTag method that returns the correct list for the current view

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
  • Changes in public API reviewed (if applicable)

nabutabu added 4 commits June 7, 2026 22:53
…elated updates

- Introduced ExcludedTagKeys property in MetricStreamConfiguration to specify optional tag keys to exclude from metrics.
- Updated AggregatorStore to handle excluded tag keys during metric updates.
- Enhanced MetricStreamIdentity to include excluded tag keys.
- Implemented validation logic to ensure TagKeys and ExcludedTagKeys are mutually exclusive.
- Added tests to verify behavior of excluded tag keys in metric views.
@github-actions github-actions Bot added the pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package label Jun 8, 2026
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.28571% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.21%. Comparing base (68bdfce) to head (b7893ac).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/OpenTelemetry/Metrics/ThreadStaticStorage.cs 79.16% 5 Missing ⚠️
src/OpenTelemetry/Metrics/AggregatorStore.cs 83.33% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7373      +/-   ##
==========================================
- Coverage   90.33%   90.21%   -0.13%     
==========================================
  Files         289      289              
  Lines       15745    15820      +75     
==========================================
+ Hits        14224    14272      +48     
- Misses       1521     1548      +27     
Flag Coverage Δ
unittests-Project-Experimental 90.21% <89.28%> (-0.11%) ⬇️
unittests-Project-Stable 90.13% <89.28%> (-0.22%) ⬇️

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

Files with missing lines Coverage Δ
src/OpenTelemetry/Metrics/Exemplar/Exemplar.cs 85.96% <100.00%> (+0.25%) ⬆️
...try/Metrics/Exemplar/FixedSizeExemplarReservoir.cs 93.33% <100.00%> (+0.74%) ⬆️
src/OpenTelemetry/Metrics/MeterProviderSdk.cs 94.30% <100.00%> (+0.16%) ⬆️
src/OpenTelemetry/Metrics/MetricStreamIdentity.cs 86.74% <100.00%> (+0.29%) ⬆️
...elemetry/Metrics/View/MetricStreamConfiguration.cs 100.00% <100.00%> (ø)
src/OpenTelemetry/ReadOnlyFilteredTagCollection.cs 100.00% <100.00%> (ø)
src/OpenTelemetry/Metrics/AggregatorStore.cs 89.63% <83.33%> (-0.47%) ⬇️
src/OpenTelemetry/Metrics/ThreadStaticStorage.cs 82.85% <79.16%> (-1.93%) ⬇️

... and 6 files with indirect coverage changes

@github-actions

Copy link
Copy Markdown
Contributor

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions Bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Jun 16, 2026
@nabutabu

Copy link
Copy Markdown
Contributor Author

Decisions that require review

TagKeys and ExcludedTagKeys combination behavior

State Behavior New in PR?
Both null All tags preserved No
TagKeys = [] All measurements collapse to zero-tag metric point No
ExcludedTagKeys = [] All tags preserved (identical to default, but goes through exclude code path) Yes
Both non-null (including both []) Validate() throws, view is dropped with a logged warning (event ID 41), instrument falls back to default behavior Yes

Order sensitivity in ExcludedTagKeys

ExcludedTagKeys uses element-wise comparison (same as TagKeys). ["a","b"] and ["b","a"] produce different MetricStreamIdentity values even though the filtering behavior is identical. This is a known limitation inherited from the pre-existing TagKeys behavior.

@nabutabu
nabutabu marked this pull request as ready for review June 16, 2026 19:03
@nabutabu
nabutabu requested a review from a team as a code owner June 16, 2026 19:03
@nabutabu nabutabu changed the title [WIP] Exclude list for tags on Metrics [Metrics] Exclude list for tags on Metrics Jun 16, 2026
@github-actions github-actions Bot removed the Stale Issues and pull requests which have been flagged for closing due to inactivity label Jun 17, 2026
Comment thread src/OpenTelemetry/Metrics/AggregatorStore.cs Outdated
Comment thread src/OpenTelemetry/Metrics/AggregatorStore.cs Outdated
Comment thread src/OpenTelemetry/Metrics/ThreadStaticStorage.cs Outdated
Comment thread src/OpenTelemetry/Metrics/View/MetricStreamConfiguration.cs
Comment thread src/OpenTelemetry/Metrics/MetricStreamIdentity.cs
This was referenced Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf Performance related pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support dropping of specific attributes from instrument

5 participants