sdk/metric: Retain advisory attributes when View has no AttributeFilter - #8859
sdk/metric: Retain advisory attributes when View has no AttributeFilter#8859dashpole wants to merge 3 commits into
Conversation
e8ff568 to
8e67a60
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8859 +/- ##
=======================================
- Coverage 88.4% 88.4% -0.1%
=======================================
Files 331 331
Lines 21001 21001
=======================================
- Hits 18572 18571 -1
- Misses 2429 2430 +1
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a Metrics SDK spec compliance gap in go.opentelemetry.io/otel/sdk/metric: when a View matches an instrument but does not specify attribute_keys (i.e., Stream.AttributeFilter is nil), the SDK now correctly falls back to the instrument’s advisory default attributes (configured via metric/x.WithDefaultAttributes) instead of treating it as “allow all attributes”.
Changes:
- Centralizes
Stream.AttributeFilterdefaulting ininserter.cachedAggregator, applying advisory default attributes when a View omits an attribute filter. - Updates pipeline unit tests and adds a meter-level regression test to cover “View matches without AttributeFilter” behavior (and preserves explicit View filter override behavior).
- Adds a changelog entry describing the fix in
go.opentelemetry.io/otel/sdk/metric.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/metric/pipeline.go | Passes instrument advisory keys into cachedAggregator and applies AttributeFilter defaulting there when Views omit it. |
| sdk/metric/pipeline_test.go | Updates cachedAggregator call sites to match the new signature. |
| sdk/metric/meter_test.go | Adds regression coverage for matched Views without an attribute filter and validates explicit filter override behavior. |
| CHANGELOG.md | Documents the user-visible behavior fix in the Unreleased “Fixed” section. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Fixes open-telemetry#8857. According to the OpenTelemetry Metrics SDK specification, if attribute_keys is not provided on a View, the SDK should use the 'Attributes' advisory parameter configured on the instrument. Previously, when a View matched an instrument without setting an AttributeFilter, the stream's AttributeFilter remained nil, causing the pipeline to drop the instrument's advisory default attributes. Centralize AttributeFilter defaulting inside cachedAggregator alongside aggregation and exemplar reservoir provider defaulting.
e5c50c0 to
45741ba
Compare
Fixes #8857.
According to the OpenTelemetry Metrics SDK specification, if attribute_keys is not provided on a View, the SDK should use the 'Attributes' advisory parameter configured on the instrument. Previously, when a View matched an instrument without setting an AttributeFilter, the stream's AttributeFilter remained nil, causing the pipeline to drop the instrument's advisory default attributes.
Centralize AttributeFilter defaulting inside cachedAggregator alongside aggregation and exemplar reservoir provider defaulting.