Skip to content

feat(attributes): Add WebSocket span name convention - #836

Merged
chargome merged 6 commits into
mainfrom
nestjs-ws-convention-a6f64926
Nov 27, 2026
Merged

chargome merged 6 commits into
mainfrom
nestjs-ws-convention-a6f64926

Conversation

@chargome

@chargome chargome commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Adds a span name convention for the websocket op, plus two new attributes: websocket.namespace and websocket.event.name.

Names follow what getsentry/sentry-javascript#26768 already emits for NestJS gateways:

  • WS {{websocket.namespace}} {{websocket.event.name}}, e.g. WS /chat message
  • WS {{websocket.event.name}}, e.g. WS joinRoom
  • WebSocket message

The span description rule uses the same attributes without the WS prefix, e.g. /chat message or joinRoom.

OTel has no WebSocket semantic conventions. Its socket.io instrumentation reuses messaging.*, but messaging.* is meant for queues and topics, and a WebSocket namespace isn't a broker entity. A separate websocket.* namespace also keeps WebSocket spans out of queue data. It isn't tied to socket.io, because NestJS also supports plain ws, which has no namespaces.

Both attributes use manual scrubbing. Event names are developer-defined strings, and namespaces can be dynamic (e.g. /tenant-123), so user-configured rules can still apply.

Refs getsentry/sentry-javascript#26768

🤖 Generated with Claude Code

Add a span name convention for the websocket op, built from the namespace
(messaging.destination.name) and the event name. Add
messaging.websocket.event.name to hold the event or message pattern,
since no messaging attribute covers it.

Requested in getsentry/sentry-javascript#26768, which names NestJS
WebSocket spans WS <namespace> <pattern>.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-conventions Ready Ready Preview Nov 27, 2026 11:00am UTC

Request Review

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (attributes) Add WebSocket span name convention by chargome and claude in #836

🤖 This preview updates automatically when you update the PR.

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

Hate to be that guy but AFAICT, the messaging namespace is mostly reserved to queues/topic messaging systems. Which I don't think websockets really can be categorized as.

For example, OTel says about messaging.destination.name

SHOULD uniquely identify a specific queue, topic or other entity within the broker.

Something else to consider, adding messaging.* attributes might make it easier for WS spans to slip into queue dashboard widgets (assuming we or users don't filter on span ops)

WDYT about adding our own websocket.* namespaced attributes? As long as there's no OTel standard, I think this should be fine. Very open to hearing other opinions on this though, so please feel free to disagree with me 😅

@chargome

Copy link
Copy Markdown
Member Author

@Lms24 I went with messaging.* mostly because OTel's socket.io instrumentation does (messaging.system: "socket.io", namespace as destination, messaging.socket.io.event_name). But you're right that a namespace isn't really a broker entity, and keeping WS spans out of queue data is a good reason on its own.

No strong feelings here. Happy to switch to websocket.namespace / websocket.event.name?

@chargome chargome self-assigned this Nov 25, 2026
messaging.* is meant for queues and topics, and a WebSocket namespace is not
a broker entity. Use websocket.namespace and websocket.event.name instead and
move the span name convention to model/name/websocket.json. Span names stay
WS <namespace> <event>.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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 making the namespace changes! Can we also add a span description rule for the spans?

chargome added a commit to getsentry/sentry-javascript that referenced this pull request Nov 26, 2026
…Socket spans

Follows the WebSocket span convention from getsentry/sentry-conventions#836, whose name
and description templates are built from these attributes. Dynamic namespaces stay unset
so the concrete child namespace doesn't end up in descriptions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
chargome added a commit to getsentry/sentry-javascript that referenced this pull request Nov 26, 2026
…Socket spans

Follows the WebSocket span convention from getsentry/sentry-conventions#836, whose name
and description templates are built from these attributes. Dynamic namespaces stay unset
so the concrete child namespace doesn't end up in descriptions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chargome
chargome merged commit a914852 into main Nov 27, 2026
19 checks passed
@chargome
chargome deleted the nestjs-ws-convention-a6f64926 branch November 27, 2026 15:03

This branch was successfully deployed

1 active deployment
Preview — 3166f3ef Deployed Nov 27, 2026 by vercel[bot]
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