Repository navigation
ref: Pass optional span attributes directly instead of conditional spreads - #25878
Merged
Merged
Conversation
Contributor
size-limit report 📦Compared: 06eb2d3 (PR test merge using develop at 365e761) Against: 365e761 (develop) · base run #64341 ✅ Baseline matches: this diff contains only this PR's changes.
|
Contributor
Optional E2E testsSome optional checks were not successful. They do not block the merge. 2 not successful, 55 successful. See the run.
Successful checks
|
…reads Span attributes that are undefined are dropped when the span is created, so wrapping them in conditional spreads is unnecessary. Co-Authored-By: Francesco Gringl-Novy <francesco.novy@sentry.io>
sentry-junior
Bot
force-pushed
the
ref/inline-optional-span-attributes
branch
from
October 30, 2026 10:22
81c531f to
29a5eea
Compare
mydea
marked this pull request as ready for review
October 30, 2026 10:25
mydea
requested review from
andreiborza,
chargome,
isaacs,
logaretm,
msonnb and
nicohrubec
and removed request for
a team
October 30, 2026 10:25
msonnb
reviewed
Oct 30, 2026
| // No conventional attribute for this; it is the only way to tell a compaction turn from a | ||
| // user-facing one. | ||
| ...(observation.purpose ? { 'flue.turn.purpose': observation.purpose } : {}), | ||
| 'flue.turn.purpose': observation.purpose, |
Member
There was a problem hiding this comment.
unrelated, but i guess we should add this to conventions?
Member
There was a problem hiding this comment.
yeah, worth looking into. may remove/change this here: #25869
msonnb
approved these changes
Oct 30, 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.
Why:
SentrySpan.setAttributedropsundefinedvalues, andSpanAttributesalready allowsundefined. That makes patterns like...(provider ? { [GEN_AI_PROVIDER_NAME]: provider } : {})unnecessary when the attributes are passed at span creation, so this passes the value directly. It also trims the browser bundle a little.I only changed attribute objects passed when a span is created, where the condition just checks the value itself. I left these alone on purpose:
setAttributeson spans that already exist. There,undefineddeletes the attribute (for example the nextjs/ember/tanstack route updates and the MCPinitializeupdate).sentry.op/sentry.origin/sentry.segment.name.source. An explicitundefinedoverrides the core defaults (the effect tracer already has a comment about this).string | null(sveltekitroute.id).nullis not a valid attribute value.''is a real case that should stay omitted. Ember has tests for this.Record<string, string | number>) and conditions on something other than the value, likehasSpanStreaming,recordInputsorsource === 'route'.Unsure about: a falsy check like
x ? {…} : {}also skipped''. Now an empty string would be set as an attribute. I don't think that can happen at the sites I changed, but it's worth a quick look.via Francesco Gringl-Novy.
--
View Junior Session [Sentry]