Skip to content

Shadow: ♻️ Replace BoundedBuffer with BufferedObservable and track dropped data via telemetry (v1)#85

Open
allspain wants to merge 3 commits into
shadow/4489/v1-basefrom
shadow/4489/v1
Open

Shadow: ♻️ Replace BoundedBuffer with BufferedObservable and track dropped data via telemetry (v1)#85
allspain wants to merge 3 commits into
shadow/4489/v1-basefrom
shadow/4489/v1

Conversation

@allspain
Copy link
Copy Markdown
Owner

Shadow Review — PR #4489 v1

Source: DataDog/browser-sdk#4489
Commit: ee5a123f689e75a6d6bb78c43054f6384f153f60
Timestamp: 2026-04-15T12:26:11Z


Original PR Description

Motivation

When API calls are made before the SDK starts, they are buffered and replayed once initialization completes. Previously this used BoundedBuffer, which silently dropped data when the buffer limit was reached. This change migrates to BufferedObservable and adds telemetry reporting when buffered data is lost, giving us visibility into potential data loss.

Changes

  • Add drop counting to BufferedObservable with an optional onDrop callback invoked on unbuffer()
  • Wire up startBufferingData to send a telemetry debug event when buffered data is dropped
  • Replace BoundedBuffer with BufferedObservable in preStartLogs and preStartRum
  • Remove the now-unused BoundedBuffer module and its tests

Test instructions

  • yarn test:unit --spec packages/core/src/tools/observable.spec.ts
  • yarn test:unit --spec packages/rum-core/src/boot/rumPublicApi.spec.ts
  • yarn test:unit --spec packages/core/src/domain/bufferedData.ts

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

Add drop counting to BufferedObservable with an optional onDrop callback
invoked on unbuffer(). Wire it up in startBufferingData to send a
telemetry debug event when buffered data is lost.
…ll buffering

- Remove deprecated BoundedBuffer module and its tests
- Migrate preStartLogs and preStartRum to use BufferedObservable with drop telemetry
- Use shared bufferContextCalls from core instead of local copy in rum-core
- Fix test assertions to await specific spies instead of startRumSpy for accuracy
- Move shared variables and setup from beforeEach into the only test
  that uses them, removing unnecessary shared state
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.

2 participants