feat(core): Make attributes required on serialized streamed spans#22053
Closed
mydea wants to merge 1 commit into
Closed
feat(core): Make attributes required on serialized streamed spans#22053mydea wants to merge 1 commit into
attributes required on serialized streamed spans#22053mydea wants to merge 1 commit into
Conversation
`SerializedStreamedSpan.attributes` was typed as optional, but a serialized streamed span always carries an `attributes` object: `streamedSpanJsonToSerializedSpan` always sets `attributes: serializeAttributes(...)`, and `serializeAttributes` always returns an object (never `undefined`). Making the field required lets consumers read `span.attributes[...]` directly without redundant optional chaining or non-null assertions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
Author
|
actually this is a duplicate of #22052 which is better, closing in favor of 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.
SerializedStreamedSpan.attributes(an exported type) was declared optional (attributes?: Attributes), but a serialized streamed span always carries anattributesobject:streamedSpanJsonToSerializedSpan()always setsattributes: serializeAttributes(...).serializeAttributes()always returns an object (an empty{}at worst), neverundefined.This makes the field required so the type matches what is actually produced. Consumers can now read
span.attributes[...]directly without redundant optional chaining or non-null assertions.Only
@sentry/coreconstructs this type; every other package consumes it read-only, so the change is safe for them — verified that the@sentry/coreand@sentry/nodetype builds still pass.This is the base of a stack:
attributesrequired on serialized streamed spans #22053 (this PR) — makeattributesrequired onSerializedStreamedSpan