fix(api): APISpan no longer exposes what it recorded - #140
Open
michaelbushe wants to merge 1 commit into
Open
michaelbushe wants to merge 1 commit into
michaelbushe wants to merge 1 commit into
Conversation
trace/api.md, Span: implementations SHOULD NOT provide access to a Span's attributes besides its SpanContext, because spans are not meant to propagate information within a process. APISpan exposed attributes, spanEvents, spanLinks, status and statusDescription. The attributes getter carried @VisibleForTesting, which is an analyzer hint: the getter was still public API and a dynamic call reached it with no warning at all. The five accessors move to a ReadableSpan, reached through getReadableSpan(span). Both are declared in a part of span.dart, because the fields they read are library-private, and both are hidden from the package barrel, so code importing the public library cannot reach them. Both carry @internal. An SDK imports src/api/trace/span.dart directly and suppresses the resulting lint at that one import. The attributes setter is unchanged. Reading back a span's status is removed from the web example, since sample code should not teach the misuse the spec warns about. Fixes #66 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
michaelbushe
force-pushed
the
fix/66-readable-span
branch
from
September 13, 2026 21:23
7374206 to
8561133
Compare
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 #66.
What
APISpanexposedattributes,spanEvents,spanLinks,statusandstatusDescription. trace/api.md, Span:The
attributesgetter carried@visibleForTesting, which is an analyzer hint only. The getter was still public API, and a dynamic call reached it with no warning at all.How
The five accessors move to a
ReadableSpan, reached throughgetReadableSpan(span). Both are declared in a new part ofspan.dart, because the fields they read are library-private, and both are hidden from the package barrel:Both carry
@internal. An SDK reaches them by importingsrc/api/trace/span.dartdirectly and suppressing the lint at that one import, the same shape as the// ignore: invalid_use_of_visible_for_testing_memberthe SDK carries today, moved to one place.The
attributessetter is unchanged.Verification
span.attributesagainst the public library and gotundefined_getter.dart analyzeclean,dart test1231 passing.getReadableSpan(...).SDK impact
This breaks
dartastic_opentelemetry'sSpan, which re-exposes all five by delegation, as @harshitt13 found on #66. Tracked separately on the SDK side. The SDK is pinned below rc.4, so nothing breaks for users until that lands and the pin is widened.Severity
SDK users are unaffected in practice: the SDK's own
Spangates every mutator on its independent recording state, so this reaches API-direct users and custom SDKs.🤖 Generated with Claude Code