Skip to content

feat(node)!: Stop inferring name for spans - #22712

Merged
mydea merged 2 commits into
developfrom
fn/name-inferral
Jul 29, 2026
Merged

feat(node)!: Stop inferring name for spans#22712
mydea merged 2 commits into
developfrom
fn/name-inferral

Conversation

@mydea

@mydea mydea commented Jul 27, 2026

Copy link
Copy Markdown
Member

Instead, we make sure to properly set the name directly whenever we start spans.

Comment thread packages/nextjs/src/server/handleOnSpanStart.ts
Comment thread packages/node/src/integrations/node-fetch/undici-instrumentation.ts Outdated
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.82 kB - -
@sentry/browser - with treeshaking flags 28.02 kB - -
@sentry/browser (incl. Tracing) 47.1 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 47.1 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.81 kB - -
@sentry/browser (incl. Tracing, Replay) 86.4 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.84 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 91.12 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 103.77 kB - -
@sentry/browser (incl. Feedback) 47.13 kB - -
@sentry/browser (incl. sendFeedback) 34.66 kB - -
@sentry/browser (incl. FeedbackAsync) 39.76 kB - -
@sentry/browser (incl. Metrics) 30.89 kB - -
@sentry/browser (incl. Logs) 31.12 kB - -
@sentry/browser (incl. Metrics & Logs) 31.8 kB - -
@sentry/react 31.6 kB - -
@sentry/react (incl. Tracing) 49.33 kB - -
@sentry/vue 34.74 kB - -
@sentry/vue (incl. Tracing) 49.05 kB - -
@sentry/svelte 29.85 kB - -
CDN Bundle 31.87 kB - -
CDN Bundle (incl. Tracing) 47.45 kB - -
CDN Bundle (incl. Logs, Metrics) 33.42 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 48.83 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 72.78 kB - -
CDN Bundle (incl. Tracing, Replay) 85.09 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.39 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 90.86 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.17 kB - -
CDN Bundle - uncompressed 95.04 kB - -
CDN Bundle (incl. Tracing) - uncompressed 142.25 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.75 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 146.23 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 224.51 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 261.51 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 265.48 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 275.22 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 279.17 kB - -
@sentry/nextjs (client) 51.92 kB - -
@sentry/sveltekit (client) 47.51 kB - -
@sentry/core/server 79.58 kB -0.01% -4 B 🔽
@sentry/core/browser 51.6 kB - -
@sentry/node 121.31 kB -0.31% -370 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B - -
@sentry/node - without tracing 84.78 kB -0.54% -455 B 🔽
@sentry/aws-serverless 93.02 kB -0.47% -436 B 🔽
@sentry/cloudflare (withSentry) - minified 197.55 kB - -
@sentry/cloudflare (withSentry) 485.69 kB - -

View base workflow run

@mydea
mydea force-pushed the fn/name-inferral branch from b3bd16b to b841d63 Compare July 28, 2026 08:27
Comment thread packages/node/src/integrations/tracing/fastify/v3/instrumentation.ts Outdated
@mydea
mydea force-pushed the fn/name-inferral branch from 8bd9f19 to 920920a Compare July 28, 2026 11:57

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 920920a. Configure here.

Comment thread dev-packages/e2e-tests/test-applications/nitro-3/tests/isolation.test.ts Outdated
Comment thread packages/solidstart/src/server/withServerActionInstrumentation.ts
@mydea
mydea force-pushed the fn/name-inferral branch from 920920a to aeefc67 Compare July 28, 2026 12:28
@mydea
mydea marked this pull request as ready for review July 29, 2026 06:37
@mydea
mydea requested review from a team as code owners July 29, 2026 06:37
@mydea
mydea requested review from andreiborza, isaacs, nicohrubec and s1gr1d and removed request for a team July 29, 2026 06:37
Comment thread packages/server-utils/src/graphql/utils.ts
@mydea
mydea force-pushed the fn/name-inferral branch from aeefc67 to b414904 Compare July 29, 2026 08:32

@andreiborza andreiborza 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.

Could we add a bugbot rule to call out that we might need to re-set source after calling span.updateName?

Also, do we still need this function? 🤔

/**
* Updates the name of the given span and ensures that the span name is not
* overwritten by the Sentry SDK.
*
* Use this function instead of `span.updateName()` if you want to make sure that
* your name is kept. For some spans, for example root `http.server` spans the
* Sentry SDK would otherwise overwrite the span name with a high-quality name
* it infers when the span ends.
*
* Use this function in server code or when your span is started on the server
* and on the client (browser). If you only update a span name on the client,
* you can also use `span.updateName()` the SDK does not overwrite the name.
*
* @param span - The span to update the name of.
* @param name - The name to set on the span.
*/
export function updateSpanName(span: Span, name: string): void {
span.updateName(name);
span.setAttributes({
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',
[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]: name,
});
}

Comment on lines 19 to 21
const ATTR_DB_MONGODB_COLLECTION = 'db.mongodb.collection';
const ATTR_DB_CONNECTION_STRING = 'db.connection_string';
const ATTR_NET_PEER_NAME = 'net.peer.name';
const ATTR_NET_PEER_PORT = 'net.peer.port';
const DB_SYSTEM_VALUE_MONGODB = 'mongodb';

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.

q: Can we add these to sentry conventions?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

probably should revisit these generally, yes!

Comment thread packages/opentelemetry/src/applyOtelSpanData.ts
Comment thread packages/core/src/integrations/http/server-subscription.ts
Comment thread dev-packages/node-integration-tests/suites/tracing/mysql/test.ts
Comment thread packages/nextjs/src/common/utils/tracingUtils.ts
Comment thread packages/nuxt/src/runtime/plugins/route-detector-legacy.server.ts

const tediousSpan = parent.spans?.find(s => s.op === 'db');
assertExists(tediousSpan, `expected a db child span, got ops: ${parent.spans?.map(s => s.op).join(', ')}`);
assertEquals(tediousSpan!.description, 'execSql mydb');

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.

l/m: IIRC descriptions should be low cardinality and be sanitized. So the output should be SELECT ? in this case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is fine because 1 is static - this is just the content of DB_STATEMENT!

@mydea

mydea commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

Could we add a bugbot rule to call out that we might need to re-set source after calling span.updateName?

yes, good idea!

Also, do we still need this function? 🤔

not really, we can probably deprecate this for the v11 cycle then.

@andreiborza andreiborza 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.

LGTM

mydea added 2 commits July 29, 2026 15:34
more fixes

moar fixes

fixxx
@mydea
mydea force-pushed the fn/name-inferral branch from b414904 to 9994c93 Compare July 29, 2026 13:34
@mydea
mydea merged commit 8f24068 into develop Jul 29, 2026
271 checks passed
@mydea
mydea deleted the fn/name-inferral branch July 29, 2026 14:13
mydea added a commit that referenced this pull request Jul 29, 2026
…22797)

Stacked on top of #22712.

With the span name/source inference reworked in #22712, core's
`getDynamicSamplingContext` now derives the DSC transaction name from
the root span and applies the `url` source guard itself. That makes the
OpenTelemetry-specific `createDsc` handler
`enhanceDscWithOpenTelemetryRootSpanName` redundant — it was only there
to re-derive the name/source via `parseSpanDescription` before core did
so natively.

This removes the util along with its call sites in `@sentry/node`,
`@sentry/vercel-edge`, and the opentelemetry test helper, and drops it
from the package's public exports.

Since the enhancer is a public export of `@sentry/opentelemetry`, its
removal is technically breaking for anyone importing it directly — which
is why this targets the breaking-change branch #22712.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

5 participants