Skip to content

feat(core): emit low cardinality request handler span names - #23614

Draft
isaacs wants to merge 3 commits into
developfrom
isaacs/low-cardinality-request-handler-span-names
Draft

feat(core): emit low cardinality request handler span names#23614
isaacs wants to merge 3 commits into
developfrom
isaacs/low-cardinality-request-handler-span-names

Conversation

@isaacs

@isaacs isaacs commented Aug 26, 2026

Copy link
Copy Markdown
Member

Name handler spans after the route they serve when span streaming is enabled, or Request handler if no route set. Static mode left as is.

Drop Hapi method, as the template dictates. NestJS resolves no route when the span starts. The NestJS callback name stays on nestjs.callback.

Elysia sets context.route when the request enters the compiled handler, which is before the Handle phase reports. Read it in the trace listener so streamed handler spans carry the route instead of the Request handler fallback. The fallback now applies only when the context has no route.

Set code.function.name only on the child spans this renames, and only when the handler has a name. Static mode keeps the handler name in the span name, so the attribute adds nothing there, and an anonymous handler has no name to record.

Register the Fastify test route from a plugin. Fastify installs the SDK's onRoute hook when it flushes its plugin list, which is after root-level routes are in place. A root-level route therefore produces no route handler span, and the test never reached that code path.

Also: correct REQUEST_HANDLER_SPAN_NAME_FALLBACK: the conventions spell the fallback Request handler, and its @see link pointed at the resource section.

closes #23533

@isaacs

isaacs commented Aug 26, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@isaacs isaacs changed the title feat(core): emit low cardinality request handler span names (#23533) feat(core): emit low cardinality request handler span names Aug 26, 2026

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3bf00a6. Configure here.

@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.57 kB - -
@sentry/browser - with treeshaking flags 26.92 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB - -
@sentry/browser (incl. Tracing) 48.59 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.6 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.51 kB - -
@sentry/browser (incl. Tracing, Replay) 88.04 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.45 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.75 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.45 kB - -
@sentry/browser (incl. Feedback) 45.81 kB - -
@sentry/browser (incl. sendFeedback) 33.36 kB - -
@sentry/browser (incl. FeedbackAsync) 38.46 kB - -
@sentry/browser (incl. Metrics) 29.51 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.43 kB - -
@sentry/react 30.31 kB - -
@sentry/react (incl. Tracing) 50.8 kB - -
@sentry/vue 35.69 kB - -
@sentry/vue (incl. Tracing) 50.82 kB - -
@sentry/svelte 28.59 kB - -
CDN Bundle 30.36 kB - -
CDN Bundle (incl. Tracing) 49.06 kB - -
CDN Bundle (incl. Logs, Metrics) 32.56 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.94 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 72.98 kB - -
CDN Bundle (incl. Tracing, Replay) 86.56 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.44 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.34 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.27 kB - -
CDN Bundle - uncompressed 89.97 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.74 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.26 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.43 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.36 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.17 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.85 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.87 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.53 kB - -
@sentry/nextjs (client) 53.34 kB - -
@sentry/sveltekit (client) 49.02 kB - -
@sentry/core/server 65.23 kB +0.03% +15 B 🔺
@sentry/core/browser 52.33 kB -0.01% -1 B 🔽
@sentry/node 121.76 kB +0.06% +70 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.18 kB - -
@sentry/node - without tracing 87.61 kB +0.1% +79 B 🔺
@sentry/aws-serverless 96.03 kB +0.1% +87 B 🔺
@sentry/cloudflare (withSentry) - minified 199.48 kB - -
@sentry/cloudflare (withSentry) 495.44 kB - -

View base workflow run

@isaacs
isaacs force-pushed the isaacs/low-cardinality-request-handler-span-names branch from 3bf00a6 to 3293c93 Compare August 26, 2026 03:19
Name `handler` spans after the route they serve when span streaming is
enabled, or `Request handler` if no route set. Static mode left as is.

Drop Hapi method, as the template dictates. NestJS resolves no
route when the span starts. The NestJS callback name stays on
`nestjs.callback`.

Elysia sets `context.route` when the request enters the compiled
handler, which is before the `Handle` phase reports. Read it in the
trace listener so streamed handler spans carry the route instead of
the `Request handler` fallback. The fallback now applies only when
the context has no route.

Set `code.function.name` only on the child spans this renames, and
only when the handler has a name. Static mode keeps the handler name
in the span name, so the attribute adds nothing there, and an
anonymous handler has no name to record.

Register the Fastify test route from a plugin. Fastify installs the
SDK's `onRoute` hook when it flushes its plugin list, which is after
root-level routes are in place. A root-level route therefore produces
no route handler span, and the test never reached that code path.

Also: correct `REQUEST_HANDLER_SPAN_NAME_FALLBACK`: the conventions
spell the fallback `Request handler`, and its `@see` link pointed at the
resource section.

closes #23533

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@isaacs
isaacs force-pushed the isaacs/low-cardinality-request-handler-span-names branch from 3293c93 to 7673348 Compare August 26, 2026 03:20

@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 1 potential issue.

Fix All in Cursor

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

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7673348. Configure here.

Comment thread packages/elysia/src/withElysia.ts
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.

Emit low cardinality request handler span names

1 participant