Skip to content

ref(core): Gate updateName() custom source on an OTel inference brand#21649

Merged
andreiborza merged 1 commit into
developfrom
ab/updatename-source
Jun 19, 2026
Merged

ref(core): Gate updateName() custom source on an OTel inference brand#21649
andreiborza merged 1 commit into
developfrom
ab/updatename-source

Conversation

@andreiborza

@andreiborza andreiborza commented Jun 18, 2026

Copy link
Copy Markdown
Member

What

SentrySpan's updateName() now sets sentry.source: 'custom' only if the span was not started by a tracer (SentryTrace in the future).

Why

With the upcoming SentryTracerProvider, that creates native SentrySpans instead of OTel SDK spans, we need a way to make sure updateName() does not set source 'custom' on all spans unconditionally. Otherwise, spans created, that had their name updated, outside of Sentry's influence (i.e. inside frameworks like nextjs) would also have source set to custom which interferes with the final source inference at the end of a span.

The need for this will be more apparent in follow-up PRs when we introduce the SentryTracerProvider and data inference that used to be done in our span exporter before.

@andreiborza andreiborza requested review from Lms24, logaretm and mydea June 18, 2026 22:09
Comment thread packages/core/src/tracing/sentrySpan.ts Outdated
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.45 kB - -
@sentry/browser - with treeshaking flags 25.88 kB - -
@sentry/browser (incl. Tracing) 45.94 kB +0.07% +28 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 47.7 kB +0.03% +10 B 🔺
@sentry/browser (incl. Tracing, Profiling) 50.73 kB +0.09% +41 B 🔺
@sentry/browser (incl. Tracing, Replay) 85.14 kB +0.04% +32 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.73 kB +0.03% +22 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 89.83 kB +0.04% +34 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 102.49 kB +0.03% +23 B 🔺
@sentry/browser (incl. Feedback) 44.62 kB - -
@sentry/browser (incl. sendFeedback) 32.25 kB - -
@sentry/browser (incl. FeedbackAsync) 37.38 kB - -
@sentry/browser (incl. Metrics) 28.52 kB - -
@sentry/browser (incl. Logs) 28.76 kB - -
@sentry/browser (incl. Metrics & Logs) 29.45 kB - -
@sentry/react 29.25 kB - -
@sentry/react (incl. Tracing) 48.24 kB +0.05% +24 B 🔺
@sentry/vue 32.61 kB +0.09% +29 B 🔺
@sentry/vue (incl. Tracing) 47.8 kB +0.06% +25 B 🔺
@sentry/svelte 27.48 kB - -
CDN Bundle 29.84 kB - -
CDN Bundle (incl. Tracing) 47.85 kB +0.06% +24 B 🔺
CDN Bundle (incl. Logs, Metrics) 31.39 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.19 kB +0.08% +37 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 70.7 kB - -
CDN Bundle (incl. Tracing, Replay) 85.21 kB +0.04% +30 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.48 kB +0.02% +17 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 91.05 kB +0.02% +17 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.31 kB +0.02% +16 B 🔺
CDN Bundle - uncompressed 88.8 kB - -
CDN Bundle (incl. Tracing) - uncompressed 144.84 kB +0.05% +59 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 93.5 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 148.81 kB +0.04% +59 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.33 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 263.7 kB +0.03% +59 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 267.66 kB +0.03% +59 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 277.4 kB +0.03% +59 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 281.35 kB +0.03% +59 B 🔺
@sentry/nextjs (client) 50.63 kB +0.05% +21 B 🔺
@sentry/sveltekit (client) 46.33 kB +0.08% +36 B 🔺
@sentry/core/server 75.85 kB +0.05% +35 B 🔺
@sentry/core/browser 63.01 kB +0.1% +62 B 🔺
@sentry/node-core 61.63 kB +0.06% +31 B 🔺
@sentry/node 124.55 kB +0.01% +10 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.05 kB - -
@sentry/node/light 50.55 kB +0.05% +21 B 🔺
@sentry/node - without tracing 74.13 kB +0.05% +33 B 🔺
@sentry/aws-serverless 85.24 kB +0.05% +38 B 🔺
@sentry/cloudflare (withSentry) - minified 172.9 kB +0.08% +121 B 🔺
@sentry/cloudflare (withSentry) 432.48 kB +0.08% +316 B 🔺

View base workflow run

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naive q: Now that we vendored in instrumentation, we can set a source whenever that instrumentation calls span.updateName, right? I wonder if we can use this to our advantage and essentially get rid of any span.updateName and updateSpanName differences.

Users who want to mark a name as intentionally chosen should use
updateSpanName() which always sets source via setAttributes().

My main concern is that this will never work reliably, as span.updateName() is the much more intuitive way to do this for users. When I added the alternative API, it was because I didn't see another way to differ between user- and instrumentation-initiated name updates. Now that we control the instrumentation, I think we could do this. WDYT?

@andreiborza

andreiborza commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

Now that we vendored in instrumentation, we can set a source whenever that instrumentation calls span.updateName, right? I wonder if we can use this to our advantage and essentially get rid of any span.updateName and updateSpanName differences.

I was thinking about this too, the problem is there are cases where we don't control the span name setting, e.g. if nextjs calls updateName on their spans

My main concern is that this will never work reliably, as span.updateName() is the much more intuitive way to do this for users.

Yeah, this is also my concern. It makes updateName weird to reason about as a maintainer as well, but I don't see away around distinguishing between user-called and instrumentation/framework called updateName.

SentrySpan's `updateName()` now sets `sentry.source: 'custom'` only if the span
was not started by a tracer (SentryTrace in the future).

With the upcoming SentryTracerProvider, that creates native SentrySpans instead
of OTel SDK spans, we need a way to make sure `updateName()` does not set source
'custom' on all spans unconditionally. Otherwise, spans created, that had their
name updated, outside of Sentry's influence (i.e. inside frameworks like nextjs)
would also have source set to custom which interferes with the final source
inference at the end of a span.

The need for this will be more apparent in follow-up PRs when we introduce the
SentryTracerProvider and data inference that used to be done in our span
exporter before.
@andreiborza andreiborza force-pushed the ab/updatename-source branch from 12d196a to e3c7978 Compare June 19, 2026 13:03
@andreiborza andreiborza changed the title fix(core): Only set source to 'custom' in updateName() when source exists ref(core): Gate updateName() custom source on an OTel inference brand Jun 19, 2026
@andreiborza andreiborza requested review from Lms24 and logaretm June 19, 2026 13:05
@andreiborza

Copy link
Copy Markdown
Member Author

I reworked the PR to use a completely different approach after discussing with @Lms24. We are gating not setting source to custom only if the span was created by a TracerProvider (which will brand Spans).

This allows us to keep the existing behavior of updateName like it is today and aligns well with Otel. Spans created via the TracerProvider mimic OTel SDK spans, meaning they don't set a source and inference does not get hung up at the end of the span as a result.

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reworking this! I think scoping this more narrowly to traceProvider-emitted spans makes sense!

@andreiborza andreiborza merged commit 2c47ed5 into develop Jun 19, 2026
282 checks passed
@andreiborza andreiborza deleted the ab/updatename-source branch June 19, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants