Fix bound instruments pinning context-derived attributes - #8782
Open
jaydeluca wants to merge 2 commits into
Open
Fix bound instruments pinning context-derived attributes#8782jaydeluca wants to merge 2 commits into
jaydeluca wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8782 +/- ##
============================================
+ Coverage 91.27% 91.30% +0.02%
- Complexity 10472 10509 +37
============================================
Files 1006 1007 +1
Lines 28277 28387 +110
Branches 3569 3588 +19
============================================
+ Hits 25811 25918 +107
Misses 1674 1674
- Partials 792 795 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jaydeluca
marked this pull request as ready for review
September 8, 2026 23:48
jack-berg
reviewed
Sep 9, 2026
| * | ||
| * <p>If the metric's view derives attributes from context (e.g. baggage), this optimization does | ||
| * not apply: each record call performs the same attribute processing and lookup as an unbound | ||
| * recording. |
Member
There was a problem hiding this comment.
Yeah this is why I want to go forward with #8719 - the machinery needed to maintain this unspecified feature is growing in size / complexity.
I think this PR is correct, but before we proceed, let's talk about #8719 at the next java SIG to see where that falls. If folks agree, then I believe we can skip 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.
ExtendedLongCounter.bind(Attributes)and its sibling APIs currently resolve their target time series at bind time. As part of that lookup, each applicable view'sAttributesProcessorruns againstContext.current(). If a view derives attributes from context (the only currently supported examples areSdkMeterProviderUtil.appendAllBaggageAttributesandappendFilteredBaggageAttributes) then subsequent measurements through the bound instrument remain pinned to the baggage that was current at bind time, rather than using the context supplied at record time.Depending on the usage pattern, this either drops the context-derived attributes entirely when binding at startup, misattributes later requests to an earlier request's baggage when a binding is reused, or eagerly creates one series per distinct bind-time baggage set when binding per request, eventually exhausting the cardinality limit.
AttributesProcessor.usesContext()prevents this eager binding and is still documented as doing so. Before bound instruments were removed,DefaultSynchronousMetricStorage.bind()returned a late-bound handle whenusesContext()was true.That guard and fallback handle were deleted from
DefaultSynchronousMetricStoragein #5157.When bound instruments returned in #8527, the new cumulative and delta bind paths processed attributes against
Context.current()without restoring that check.