Skip to content

♻️ Route fetch, XHR, and console through bufferedDataObservable#4470

Draft
thomas-lebeau wants to merge 1 commit intov7from
thomas.lebeau/unify-buffered-observables
Draft

♻️ Route fetch, XHR, and console through bufferedDataObservable#4470
thomas-lebeau wants to merge 1 commit intov7from
thomas.lebeau/unify-buffered-observables

Conversation

@thomas-lebeau
Copy link
Copy Markdown
Collaborator

Motivation

Centralize the buffering of fetch, XHR, and console observables into bufferedDataObservable instead of each observable managing its own buffer. This simplifies the pre-start data flow and removes the need for early instrumentation (subscribe(noop)) and product-specific wrappers like trackConsoleError.

Changes

  • Add FETCH, XHR, and CONSOLE types to the BufferedData discriminated union with a consistent { type, data } shape
  • Subscribe to fetch/xhr/console observables in startBufferingData() so buffering is centralized
  • Update Logs and RUM consumers to receive network and console events via bufferedDataObservable instead of subscribing directly to each observable
  • Convert fetchObservable/xhrObservable/consoleObservable from BufferedObservable to plain Observable (buffering now centralized)
  • Remove early instrumentation (subscribe(noop)) from pre-start phases
  • Remove trackConsoleError (replaced by console handling in errorCollection)

Test instructions

  • Run yarn test:unit to verify all unit tests pass
  • Verify that fetch, XHR, and console errors are still collected correctly during pre-start and post-start phases

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

@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/unify-buffered-observables branch from e98e9d5 to 629186b Compare April 10, 2026 14:52
@cit-pr-commenter-54b7da
Copy link
Copy Markdown

cit-pr-commenter-54b7da bot commented Apr 10, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 166.98 KiB 167.23 KiB +251 B +0.15%
Rum Profiler 6.09 KiB 6.09 KiB 0 B 0.00%
Rum Recorder 27.10 KiB 27.10 KiB 0 B 0.00%
Logs 53.76 KiB 53.78 KiB +21 B +0.04%
Rum Slim 125.39 KiB 125.64 KiB +255 B +0.20%
Worker 22.99 KiB 22.99 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.0051 0.0044 -13.73%
RUM - add action 0.0194 0.0129 -33.51%
RUM - add error 0.0176 0.0124 -29.55%
RUM - add timing 0.0028 0.0025 -10.71%
RUM - start view 0.0146 0.0125 -14.38%
RUM - start/stop session replay recording 0.001 0.0007 -30.00%
Logs - log message 0.0161 0.0158 -1.86%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 33.47 KiB 33.73 KiB +264 B
RUM - add action 246.93 KiB 121.33 KiB -125.60 KiB
RUM - add timing 35.63 KiB 35.23 KiB -416 B
RUM - add error 251.33 KiB 126.99 KiB -124.35 KiB
RUM - start/stop session replay recording 35.75 KiB 35.90 KiB +162 B
RUM - start view 614.86 KiB 531.89 KiB -82.98 KiB
Logs - log message 244.74 KiB 49.23 KiB -195.50 KiB

🔗 RealWorld

@datadog-datadog-prod-us1-2
Copy link
Copy Markdown

datadog-datadog-prod-us1-2 bot commented Apr 10, 2026

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Other Violations

🧪 1 Test failed

microfrontend › RUM › with source code bundler plugin › xhr requests should have service and version from source code context from microfrontend.scenario.ts   View in Datadog   (Fix with Cursor)
microfrontend.scenario.ts:314:17 xhr requests should have service and version from source code context

[Webkit] › microfrontend.scenario.ts:314:17 › microfrontend › RUM › with source code bundler plugin › xhr requests should have service and version from source code context 

    Error: expect(received).toMatchObject(expected)

    - Expected  - 10
    + Received  +  1

    - Array [
...

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 80.22%
Overall Coverage: 78.15%

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 27309cc | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/unify-buffered-observables branch from 629186b to 496df82 Compare April 13, 2026 05:45
- Add FETCH, XHR, and CONSOLE types to BufferedData discriminated union
- Subscribe to fetch/xhr/console observables in startBufferingData()
- Update Logs and RUM consumers to receive network and console events
  via bufferedDataObservable instead of subscribing directly
- Remove early instrumentation (subscribe(noop)) from preStart phases
- Remove trackConsoleError (replaced by console handling in errorCollection)
- Convert fetchObservable/xhrObservable/consoleObservable from
  BufferedObservable to plain Observable (buffering now centralized)
- Normalize BufferedData shape to use { type, data } consistently
@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/unify-buffered-observables branch from 496df82 to 27309cc Compare April 13, 2026 10:31
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