Extend Attribute API with optional AttributesLimits, including count, length, and depth - #8656
Draft
jack-berg wants to merge 7 commits into
Draft
Extend Attribute API with optional AttributesLimits, including count, length, and depth#8656jack-berg wants to merge 7 commits into
jack-berg wants to merge 7 commits into
Conversation
…y-java into api-attribute-limits
Contributor
|
Pull request dashboard statusStatus last refreshed: 2026-07-24 16:20:55 UTC.
This automated status or its linked feedback items may be incorrect. If something looks wrong, please report it with the result you expected. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8656 +/- ##
============================================
+ Coverage 91.46% 91.57% +0.10%
- Complexity 10457 10492 +35
============================================
Files 1021 1023 +2
Lines 27647 27735 +88
Branches 3242 3251 +9
============================================
+ Hits 25288 25397 +109
+ Misses 1616 1599 -17
+ Partials 743 739 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jack-berg
commented
Jul 24, 2026
| private int countLimit = Integer.MAX_VALUE; | ||
| private int valueLengthLimit = Integer.MAX_VALUE; | ||
|
|
||
| // TODO(jack-berg): before merging, decide whether to default this to 64 (spec-recommended, |
jack-berg
commented
Jul 24, 2026
| return result; | ||
| } | ||
|
|
||
| // TODO(jack-berg): convert to iterative traversal (explicit stack) to guarantee no |
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.
Fixes #7897.
Embodies "approach 3" from this comment.
Adds
AttributeLimitsandAttributes.builder(AttributeLimits)toopentelemetry-api, giving users (and the SDK) a way to build attributes that enforce the OpenTelemetry common attribute-limits rules: count limit, value length limit, and (soon) value depth limit.getCountLimitvs.SpanLimits.getMaxNumberOfAttributesgetValueLengthLimitvs.SpanLimits.getMaxAttributeValueLengthgetValueDepthLimitvs no current SpanLimits equivalent>= 1(depth is 1-indexed per spec).Attributes.builder()is equivalent toAttributes.builder(AttributeLimits.noLimits()).putby key name (regardless of type), truncates over-length strings and byte arrays, replaces over-nested arrays and maps with empty containers, drops entries beyond the count limit. Overwrites do not consume against the count limit.SDK integration:
AttributesMapinsdk-commonis deleted.SdkSpan,SdkSpanBuilder,SdkLogRecordBuilder,SdkReadWriteLogRecordnow store anAttributesBuilderobtained viaAttributes.builder(AttributeLimits)and tracktotalAttributeCountlocally.SpanLimits.getMaxNumberOfAttributes/getMaxAttributeValueLengthare still the source of truth for span attribute limits. Wiring depth throughSpanLimits/LogLimitsis deferred for now.Performance:
Extended
AttributesBenchmarkwith a few more relevant cases. See before and after below:Details