Add support for excluding attributes in metrics View - #5332
Add support for excluding attributes in metrics View#5332saurabh-saraswat wants to merge 24 commits into
Conversation
xrmx
left a comment
There was a problem hiding this comment.
Looks like you haven't run the tests locally
|
@xrmx . I have updated the pull request for the comments provided. Local tests was passing. |
There was a problem hiding this comment.
Pull request overview
Adds View-level support for excluding specific attribute keys from metric stream identity, aligning the Python SDK View API with the Metrics SDK spec’s exclude-list behavior (issue #5331).
Changes:
- Introduces
exclude_attribute_keysonViewand applies it during measurement consumption to remove matching keys before stream identification. - Updates declarative meter provider configuration to map
attribute_keys.excludedintoView(exclude_attribute_keys=...). - Adds/updates unit tests and changelog entry for the new behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/view.py | Adds exclude_attribute_keys to the View API and stores it for later use. |
| opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/_view_instrument_match.py | Applies the exclude-list while building the attribute set used for aggregation keying. |
| opentelemetry-sdk/src/opentelemetry/sdk/_configuration/_meter_provider.py | Wires declarative config’s excluded attribute keys into the SDK View. |
| opentelemetry-sdk/tests/metrics/test_view_instrument_match.py | Adds tests validating exclude-list behavior and include-then-exclude precedence. |
| opentelemetry-sdk/tests/_configuration/test_meter_provider.py | Updates config test to assert excluded attribute keys are applied to View. |
| .changelog/5332.added | Documents the added View(exclude_attribute_keys=...) support. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
saurabh-saraswat
left a comment
There was a problem hiding this comment.
Updated for github review comments
saurabh-saraswat
left a comment
There was a problem hiding this comment.
I have incorporated comments, let me know if something is pending from my side
Co-authored-by: Riccardo Magliocchetti <[email protected]>
09c05af to
3d15f96
Compare
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Apply suggestion from @herin049 for making attribute_keys and exclude_attribute_keys as list Co-authored-by: Lukas Hering <[email protected]>
For considering for not considering exclude_attribute_keys as set Co-authored-by: Lukas Hering <[email protected]>
Not considering attribute_keys as set Co-authored-by: Lukas Hering <[email protected]>
…attribute_keys, raising of Exception if there is overlap between include attribute and exclude attribute
Description
Added support for parameter exclude_attribute_keys in View. During consume_measurement removed the attributes which were in exclude_attribute_keys
Fixes #5331
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Contrib Repo Change?
No
Checklist: