Repository navigation
[SDK] Skip empty span links - #4772
Open
hidingmyname wants to merge 2 commits into
Open
hidingmyname wants to merge 2 commits into
hidingmyname wants to merge 2 commits into
Conversation
A link with an invalid span context, no attributes and no trace state carries no information. Skip it when links are passed at span creation and in AddLink/AddLinks (ABI v2), so it no longer takes a slot under link_count_limit. This matches the Go, Java and Python SDKs. Fixes open-telemetry#4749
hidingmyname
force-pushed
the
sdk-skip-empty-span-links-4749
branch
from
November 8, 2026 01:56
d6198fc to
d94021e
Compare
mateenali66
approved these changes
Nov 9, 2026
mateenali66
left a comment
Member
There was a problem hiding this comment.
LGTM, thanks for the fix.
Under ABI v2, SpanSkipsEmptyLinks fails with the filter removed from any of the three call sites, or with either clause of IsEmptyLink dropped.
The rule matches the spec text on links with an empty TraceId or SpanId.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4772 +/- ##
==========================================
+ Coverage 86.61% 86.62% +0.02%
==========================================
Files 530 530
Lines 21169 21176 +7
==========================================
+ Hits 18333 18342 +9
+ Misses 2836 2834 -2
🚀 New features to boost your workflow:
|
Resolve the include-what-you-use diagnostics for the empty-link fix.
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.
Fixes #4749
Changes
A span link whose span context is invalid and which has no attributes and no
trace state carries no information. The SDK recorded such links anyway, so an
empty link could take a slot under
link_count_limitand push out a real one(with
link_count_limit = 1and links{empty, valid}, the empty link waskept and the valid one dropped).
Spannow skips these links in all three places links are recorded: linkspassed at span creation, and
AddLink/AddLinks(ABI v2). An invalidcontext that still has attributes or a non-empty trace state is kept, as
before.
This is the same rule used by the Go (
recordingSpan.AddLink), Java(
SdkSpan.addLink) and Python (_is_valid_link) SDKs.Tests: new
Tracer.SpanSkipsEmptyLinksinsdk/test/trace/tracer_test.cc:link_count_limit = 1, links{empty, valid}: the valid link is recordedand 0 links are dropped.
AddLink/AddLinkswith an empty link record nothing, and afollowing valid link is kept with 0 dropped.
Without the change in
span.ccthe new test fails (the empty link isrecorded and the valid one dropped), under both ABI v1 and ABI v2 (including
the
AddLink/AddLinkscase); with it, it passes.Results (CMake, Debug, GCC 15.3, clang-format 18):
sdk/test/tracepass (174/174 via ctest;tracer_test45/45).WITH_ABI_VERSION_2=ON):tracer_test48/48 pass, includingSpanSkipsEmptyLinkswith theAddLink/AddLinkscases and the existingSpanAddLinkAbiv2,SpanAddLinksAbiv2,SpanMixLinksAbiv2.For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes