Repository navigation
Retain invalid span links with attributes or trace state - #8917
Merged
jack-berg merged 1 commit intoOct 19, 2026
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e115342e-020d-4c4b-92ad-4cb6b5c06b2d
There was a problem hiding this comment.
🟢 Approval recommended
The implementation matches the tracing specification and is comprehensively covered across SDK paths and serialization.
0 open findings
What changed in this PR
Updates tracing APIs and SDK behavior to retain invalid span links when attributes or trace state provide useful metadata.
Changes:
- Retains qualifying invalid links before and after span creation.
- Preserves limits, ordering, sampling input, and original attribute counts.
- Adds SDK and OTLP serialization coverage.
| File | Description |
|---|---|
api/all/.../Span.java |
Documents invalid-link behavior. |
api/all/.../SpanBuilder.java |
Documents builder behavior. |
sdk/trace/.../SdkSpan.java |
Retains qualifying runtime links. |
sdk/trace/.../SdkSpanBuilder.java |
Retains qualifying creation-time links. |
sdk/trace/.../SdkSpanTest.java |
Tests runtime links and limits. |
sdk/trace/.../SdkSpanBuilderTest.java |
Tests builder links, limits, and sampling. |
exporters/otlp/.../TraceRequestMarshalerTest.java |
Verifies invalid-context OTLP encoding. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8917 +/- ##
============================================
+ Coverage 90.58% 90.60% +0.01%
- Complexity 10742 10749 +7
============================================
Files 1007 1007
Lines 29205 29210 +5
Branches 3786 3788 +2
============================================
+ Hits 26456 26466 +10
+ Misses 1850 1847 -3
+ Partials 899 897 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Pull request dashboard statusMerged · refreshed 2026-10-19 20:12 UTC Status above doesn't look right?
|
trask
marked this pull request as ready for review
October 8, 2026 21:19
jack-berg
approved these changes
Oct 19, 2026
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.
The SDK now retains links with invalid IDs when their attributes or trace state are nonempty, following the tracing API's SHOULD recommendation:
This applies to links added both before and after span creation.
Eligibility is checked before attribute truncation. Null contexts and empty invalid links remain ignored; trace flags alone do not qualify.
Existing link limits, ordering, and sampling behavior apply. Links added after span creation also preserve the original attribute count for dropped-attribute reporting.
SDK portion of open-telemetry/opentelemetry-java-instrumentation#20272.