opentelemetry-sdk: add support for exclude list for metric attribute keys on Views#5447
Closed
herin049 wants to merge 2 commits into
Closed
opentelemetry-sdk: add support for exclude list for metric attribute keys on Views#5447herin049 wants to merge 2 commits into
herin049 wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds OpenTelemetry Metrics SDK support for configuring an exclude list of metric attribute keys on Views, aligning behavior with the Views specification guidance and propagating that capability through declarative configuration.
Changes:
- Extends
Viewto acceptexcluded_attribute_keysand validates it does not overlap withattribute_keys. - Applies include/exclude attribute-key filtering in
_ViewInstrumentMatch.consume_measurement. - Updates configuration parsing and expands unit tests to cover excluded keys behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/view.py | Adds excluded_attribute_keys to View, normalizes inputs, and validates include/exclude overlap. |
| opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/_view_instrument_match.py | Implements attribute filtering logic that supports both include and exclude sets. |
| opentelemetry-sdk/tests/metrics/test_view.py | Adds tests for include/exclude overlap, disjoint keys, and normalization behavior. |
| opentelemetry-sdk/tests/metrics/test_view_instrument_match.py | Adds tests asserting excluded keys are dropped during measurement consumption. |
| opentelemetry-configuration/src/opentelemetry/configuration/_meter_provider.py | Maps declarative config attribute_keys.excluded into SDK View(excluded_attribute_keys=...). |
| opentelemetry-configuration/tests/test_meter_provider.py | Updates tests to assert excluded keys are passed through (instead of warning/ignoring). |
| .changelog/5447.added | Adds changelog entry for the new View exclude-list feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+149
to
+153
| excluded_attribute_keys = ( | ||
| frozenset(excluded_attribute_keys) | ||
| if excluded_attribute_keys is not None | ||
| else None | ||
| ) |
Comment on lines
260
to
264
| name=stream.name, | ||
| description=stream.description, | ||
| attribute_keys=attribute_keys, | ||
| excluded_attribute_keys=excluded_attribute_keys, | ||
| aggregation=aggregation, |
Contributor
|
Isn't this a dup of #5332? |
Contributor
Author
Thanks, missed this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds support for configuring an exclude list for metric attribute keys for Views.
Fixes #5446
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Does This PR Require a Contrib Repo Change?
Checklist: