Skip to content

feat(nestjs): Emit low cardinality @OnEvent function span name - #24588

Merged
Lms24 merged 1 commit into
developfrom
fix/nestjs-function-span-names
Sep 23, 2026
Merged

Lms24 merged 1 commit into
developfrom
fix/nestjs-function-span-names

Conversation

@Lms24

@Lms24 Lms24 commented Sep 22, 2026

Copy link
Copy Markdown
Member

The @OnEvent handler span was named event <name> and set no code.function.name at all. Both the name and the description conventions for the function op are built from that attribute, so the event prefix came from nowhere the conventions know about and Relay inferred no description for these spans. Cardinality was never the issue here — event names come from decorator metadata — the shape was.

The span is now named after the event the handler listens to, with that set as code.function.name; the prefixed name moves to sentry.description on the streaming branch. This mirrors the bullmq helper directly below it, which already handled both lifecycles this way. Note that these spans are forceTransaction: true, so this changes the segment name (and sentry.segment.name) for event handlers — event myEvent.pass becomes myEvent.pass.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.23 kB - -
@sentry/browser - with treeshaking flags 27.5 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.4 kB - -
@sentry/browser (incl. Tracing) 51.16 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 51.17 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.16 kB - -
@sentry/browser (incl. Tracing, Replay) 90.75 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.85 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 95.45 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 108.42 kB - -
@sentry/browser (incl. Feedback) 46.76 kB - -
@sentry/browser (incl. sendFeedback) 34.29 kB - -
@sentry/browser (incl. FeedbackAsync) 39.39 kB - -
@sentry/browser (incl. Metrics) 30.25 kB - -
@sentry/browser (incl. Logs) 30.5 kB - -
@sentry/browser (incl. Metrics & Logs) 31.17 kB - -
@sentry/react 30.98 kB - -
@sentry/react (incl. Tracing) 53.44 kB - -
@sentry/vue 36.72 kB - -
@sentry/vue (incl. Tracing) 53.69 kB - -
@sentry/svelte 29.25 kB - -
CDN Bundle 30.93 kB - -
CDN Bundle (incl. Tracing) 51.69 kB - -
CDN Bundle (incl. Logs, Metrics) 33.19 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.66 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.92 kB - -
CDN Bundle (incl. Tracing, Replay) 89.27 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.23 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 95.43 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 97.4 kB - -
CDN Bundle - uncompressed 91.4 kB - -
CDN Bundle (incl. Tracing) - uncompressed 153.76 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.97 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 159.72 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 227.54 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 273.5 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 279.43 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.2 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 293.13 kB - -
@sentry/nextjs (client) 55.78 kB - -
@sentry/sveltekit (client) 51.59 kB - -
@sentry/core/server 39.92 kB - -
@sentry/core/browser 13.63 kB - -
@sentry/node 133.88 kB +0.02% +16 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.4 kB - -
@sentry/node - without tracing 90.39 kB +0.01% +7 B 🔺
@sentry/node - without channel injection 112.42 kB +0.02% +21 B 🔺
@sentry/aws-serverless 98.71 kB +0.03% +22 B 🔺
@sentry/cloudflare (withSentry) - minified 206.34 kB - -
@sentry/cloudflare (withSentry) 513.42 kB - -

View base workflow run

@Lms24
Lms24 marked this pull request as ready for review September 22, 2026 12:13
@Lms24
Lms24 requested a review from a team as a code owner September 22, 2026 12:13
@Lms24
Lms24 requested review from nicohrubec and s1gr1d and removed request for a team September 22, 2026 12:13
Comment thread packages/nestjs/test/integrations/orchestrion-subscriber.test.ts
@Lms24
Lms24 force-pushed the fix/nestjs-function-span-names branch from 267138b to 12100c6 Compare September 22, 2026 16:06
@Lms24 Lms24 changed the title fix(nestjs): Follow the function conventions for @OnEvent span names feat(nestjs): Emit low cardinality @OnEvent function span name Sep 23, 2026
name: `event ${event}`,
// With span streaming, a `function` span is named after what it wraps. An `@OnEvent` handler is
// identified by the event it listens to, so that doubles as its `code.function.name`.
name: isStreamed ? event : description,

@JPeer264 JPeer264 Sep 23, 2026

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: Should we maybe keep one test for transactions? (not a blocker for this PR)

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.

yup, we probably should. let me follow up with a test

The `@OnEvent` handler span was named `event <name>` and set no
`code.function.name`, so the `event ` prefix was derivable from nothing
and Relay could infer no description at all for it. Both the name and
the description conventions for the `function` op are built from
`code.function.name`.

Name the span after the event the handler listens to and set that as
`code.function.name`. The event is the closest thing to an identity the
SDK has for an `@OnEvent` handler, and it is what made the old name
useful. The prefixed name moves to `sentry.description`, matching what
the bullmq helper next to it already does.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Lms24
Lms24 force-pushed the fix/nestjs-function-span-names branch from 12100c6 to 5010864 Compare September 23, 2026 07:01
@Lms24
Lms24 merged commit 3fd9249 into develop Sep 23, 2026
57 checks passed
@Lms24
Lms24 deleted the fix/nestjs-function-span-names branch September 23, 2026 07:16
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.

4 participants