Skip to content

✨ Report WebSocket silences and send queue depth, and protect WebSocket vitals in beforeSend - #5096

Open
bdibon wants to merge 5 commits into
boris.dibon/websocket-vitals-4-pulsefrom
boris.dibon/websocket-vitals-5-metrics-beforesend
Open

bdibon wants to merge 5 commits into
boris.dibon/websocket-vitals-4-pulsefrom
boris.dibon/websocket-vitals-5-metrics-beforesend

Conversation

@bdibon

@bdibon bdibon commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Completes the snapshot with the metrics that depend on when it is read or when tracking ended, and protects the vital stream in beforeSend: the backend derives each connection from all its vitals, so a dismissed one would corrupt it, while a few fields can carry customer data and must stay redactable.

Part of the WebSocket vitals stack. Every PR targets the previous one; the first one targets the boris.dibon/websocket-vitals integration branch, which is merged into main in one go once the whole stack is approved. #5055 stays open as the reference implementation: the tip of this stack is content-identical to it, rebased on the current main.

  1. 🔧 Pin rum-events-format and add WebSocket test utilities #5092 🔧 Pin rum-events-format and add WebSocket test utilities
  2. ✨ Collect connecting, open and closed WebSocket vitals #5093 ✨ Collect connecting, open and closed WebSocket vitals
  3. ✨ Report the websocket_closing vital #5094 ✨ Report the websocket_closing vital
  4. ✨ Pulse open WebSocket vitals on a shared heartbeat #5095 ✨ Pulse open WebSocket vitals on a shared heartbeat
  5. ✨ Report WebSocket silences and send queue depth, and protect WebSocket vitals in beforeSend #5096 ✨ Report WebSocket silences and send queue depth, and protect WebSocket vitals in beforeSend 👈 this PR
  6. ✨ End WebSocket tracking when the page is discarded #5097 ✨ End WebSocket tracking when the page is discarded

Changes

Commit by commit:

  • ✨ Report the time to first message and the silences of a WebSocket connection: time_to_first_message per direction. longest_silence now counts the gap still open when the snapshot is read: at the pulse while open (so a quiet connection grows its silence across pulses), at the tracking end once closed. The closed vital adds silence_before_close.
  • ✨ Report the WebSocket send queue depth at close: buffered_amount_at_close on the closed vital, from the close event, or read from the socket when tracking ended without one.
  • ✨ Make WebSocket vitals non-dismissible from beforeSend: like views, a WebSocket vital beforeSend returns false for is kept, with a warning.
  • ✨ Let beforeSend redact the sensitive fields of WebSocket vitals: vital.websocket.url, requested_protocols, selected_protocol and close_reason are modifiable; every other field stays read-only. The betaTrackWebSockets doc says so.
  • ✅ Cover WebSocket metrics and beforeSend end to end

Test instructions

  • Unit: yarn test:unit --spec "packages/browser-rum-core/src/domain/webSocket/*.spec.ts" --spec packages/browser-rum-core/src/browser/webSocketObservable.spec.ts --spec packages/browser-rum-core/src/domain/assembly.spec.ts
  • E2E: yarn test:e2e -g "rum websockets"

Note

check-staging-merge is expected to fail: staging-40 already contains the earlier merge of #5055, which touches the same files. It clears at the next staging bump; the other checks should be green.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@bdibon bdibon mentioned this pull request Oct 1, 2026
3 of 5 tasks
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 1 Pipeline job failed

DataDog/browser-sdk | check-staging-merge

View more details · View in GitLab

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog auto-retried 1 job - 1 passed on retry View in Datadog

🎯 Code Coverage (details)
• Patch Coverage: 77.27%
• Overall Coverage: 77.38% (-0.00%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: da81893 | Docs | View more details | Give us feedback!

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce N/A 187.94 KiB N/A N/A N/A
Rum 186.79 KiB 187.92 KiB +1.13 KiB +0.61% ✅
Rum-salesforce Profiler N/A 8.35 KiB N/A N/A N/A
Rum Profiler 8.35 KiB 8.35 KiB 0 B 0.00% ✅
Rum-salesforce Recorder N/A 31.94 KiB N/A N/A N/A
Rum Recorder 31.94 KiB 31.94 KiB 0 B 0.00% ✅
Logs 59.00 KiB 59.00 KiB 0 B 0.00% ✅
Rum Slim 144.75 KiB 145.83 KiB +1.08 KiB +0.74% ✅
Worker 22.96 KiB 22.96 KiB 0 B 0.00% ✅
Rum Shopify N/A 218.33 KiB N/A N/A N/A
Rum-shopify Profiler N/A 8.35 KiB N/A N/A N/A
Rum-shopify Recorder N/A 4.77 KiB N/A N/A N/A

@bdibon
bdibon force-pushed the boris.dibon/websocket-vitals-5-metrics-beforesend branch from 950c462 to 76590b9 Compare October 1, 2026 11:59
@bdibon bdibon changed the title ✨ Make WebSocket vitals non-dismissible and redactable ✨ Report WebSocket silences and send queue depth, and protect WebSocket vitals in beforeSend Oct 1, 2026
@bdibon
bdibon added this pull request to stack #5099 October 1, 2026 12:13
@bdibon
bdibon marked this pull request as ready for review October 1, 2026 12:18
@bdibon
bdibon requested a review from a team as a code owner October 1, 2026 12:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-07T17:05:35.410084Z da81893 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 76590b933d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/browser-rum-core/src/domain/webSocket/trackedConnection.ts Outdated
Comment thread packages/browser-rum-core/src/domain/webSocket/trackedConnection.ts
bdibon and others added 5 commits October 7, 2026 18:57
…nnection

Each direction now reports the time from the open date to its first message, and longest_silence counts the gap still open when the snapshot is read: at the pulse while open, so a quiet connection grows its silence across pulses, and at the tracking end once closed. The closed vital also reports the silence before close.

Co-authored-by: Cursor <cursoragent@cursor.com>
The closed vital reports buffered_amount_at_close: the queue depth the close event carried, or the one read from the socket when tracking ended without a close event. Bytes still queued at close are payloads the application sent that may never have reached the server.

Co-authored-by: Cursor <cursoragent@cursor.com>
The backend derives each connection from its whole vital stream, so dismissing some of its vitals would corrupt it. Like view events, a WebSocket vital beforeSend returns false for is kept, with a warning. To collect none, leave betaTrackWebSockets off.

Co-authored-by: Cursor <cursoragent@cursor.com>
The fields that can carry customer data are modifiable from beforeSend: the url, the requested and selected protocols (often used to pass tokens) and the close reason. Every other WebSocket vital field stays read-only.

Co-authored-by: Cursor <cursoragent@cursor.com>
A quiet connection grows longest_silence across pulses, beforeSend cannot dismiss WebSocket vitals but can redact their sensitive fields, and changes to any other field are ignored.

Co-authored-by: Cursor <cursoragent@cursor.com>
@bdibon
bdibon force-pushed the boris.dibon/websocket-vitals-5-metrics-beforesend branch from 76590b9 to da81893 Compare October 7, 2026 17:01

This branch has not been deployed

No deployments
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.

1 participant