Repository navigation
Test exemplars retain attributes dropped by the Attributes advice - #9032
Open
amalsaidov wants to merge 1 commit into
Open
amalsaidov wants to merge 1 commit into
amalsaidov wants to merge 1 commit into
Conversation
The Attributes instrument advisory parameter filters attributes out of a metric point. Per the metrics SDK spec, those dropped attributes must still be recorded on sampled exemplars as filtered attributes, so joining an exemplar's filtered attributes with its point's attributes reconstructs the original measurement. View attribute filtering already has this coverage, but the advice path did not. Add end-to-end tests covering a counter and a histogram, plus the case where a matching View supersedes the advice and the exemplar retains the attributes dropped by the View instead. Signed-off-by: amalsaidov <amalsaidov@users.noreply.github.com>
|
Pull request dashboard statusWaiting on the author · refreshed 2026-11-13 01:59 UTC Investigate required status check failures. Status above doesn't look right?
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9032 +/- ##
============================================
- Coverage 90.46% 90.46% -0.01%
+ Complexity 11152 11151 -1
============================================
Files 1028 1028
Lines 30382 30382
Branches 3966 3966
============================================
- Hits 27486 27485 -1
Misses 1922 1922
- Partials 974 975 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Why
The
Attributesinstrument advisory parameter acts as an allow-list of attribute keys to keep on a metric point. Attributes it filters out must still be recorded on sampled exemplars as filtered attributes, so that joining an exemplar's filtered attributes with its point's attributes reconstructs the original measurement. This was recently clarified in the spec (open-telemetry/opentelemetry-specification#5392) and tracked here in #8990.View attribute filtering already has exemplar coverage (
BoundInstrumentExemplarTest,SdkLongHistogramTest), but the advice path (applyAdviceToDefaultView->AttributesFilters.byAdvice) had no end-to-end exemplar test, even though it flows through the same record path. The current SDK already behaves correctly here; these tests lock that in.What
Adds three tests to
AttributesAdviceTest:I confirmed the tests gate by temporarily making the synchronous record path offer the filtered attributes to the reservoir (the pre-clarification behavior): the exemplar's filtered attributes came back empty and the counter test failed. With the current code all three pass.
Ran
./gradlew :sdk:metrics:testIncubating --tests io.opentelemetry.sdk.metrics.AttributesAdviceTest(passing) and:sdk:metrics:spotlessApply.Addresses #8990.
AI-assisted; directed, reviewed and tested by the author (amalsaidov).