refactor(realtime): introduce RealtimeObservability orchestrator (PR 1 of 3)#132
Merged
Conversation
commit: |
AdirAmsalem
reviewed
May 13, 2026
|
|
||
| let webrtcManager: WebRTCManager | undefined; | ||
| const observability = new RealtimeObservability({ | ||
| telemetryEnabled: false, |
Contributor
There was a problem hiding this comment.
Is this disabled on purpose?
| this.observability = | ||
| callbacks.observability ?? | ||
| new RealtimeObservability({ | ||
| telemetryEnabled: false, |
| callbacks.observability ?? | ||
| new RealtimeObservability({ | ||
| telemetryEnabled: false, | ||
| apiKey: "", |
| this.observability = | ||
| config.observability ?? | ||
| new RealtimeObservability({ | ||
| telemetryEnabled: false, |
| config.observability ?? | ||
| new RealtimeObservability({ | ||
| telemetryEnabled: false, | ||
| apiKey: "", |
VerioN1
pushed a commit
that referenced
this pull request
May 13, 2026
## Summary - Propagate the SDK `telemetryEnabled` option through the realtime subscribe path instead of forcing telemetry off. - Require injected `RealtimeObservability` in `WebRTCManager` / `WebRTCConnection`, removing the hard-coded disabled observability fallback with an empty API key. - Rename inter-frame delay `Variance` stat to `StdDev` to match the actual computation. ## Checks - `pnpm --filter @decartai/sdk typecheck` - `pnpm --filter @decartai/sdk format:check` (passes with existing warnings/info) - `pnpm --filter @decartai/sdk test -- --run` - `pnpm --filter @decartai/sdk build` (passes; existing tsdown warning about `define` option) - Independent Claude Code review of diff vs `origin/alon/livekit-pr1-observability` Base for #132. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes realtime telemetry behavior (subscribe path now honors `telemetryEnabled`) and makes `WebRTCManager`/`WebRTCConnection` require an injected `RealtimeObservability`, which can be a breaking change for any consumers constructing these classes directly. Renaming a `WebRTCStats` field also risks downstream type/runtime expectations. > > **Overview** > Realtime subscribe sessions now honor the SDK’s `telemetryEnabled` option and immediately call `observability.sessionStarted(sid)` so telemetry/diagnostics are associated with the session. > > `WebRTCManager` and `WebRTCConnection` no longer create an internal fallback `RealtimeObservability` (previously hard-coded telemetry off with an empty API key); callers must pass `observability` explicitly, and unit tests are updated accordingly. > > In `WebRTCStats`, the inter-frame delay metric is renamed from `interFrameDelayVarianceMs` to `interFrameDelayStdDevMs` to match the actual std-dev calculation. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 16388f0. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…1 of 3) Move diagnostics/telemetry/stats into a single observability/ folder. Adds RealtimeObservability orchestrator that owns telemetry reporting, stats collection, and diagnostic emission. WebRTCStats gains ~20 standard RTCStats fields. aiortc (webrtc-manager + webrtc-connection) migrates onto the orchestrator. No LiveKit code, no new dependencies, no public API break. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Propagate the SDK `telemetryEnabled` option through the realtime subscribe path instead of forcing telemetry off. - Require injected `RealtimeObservability` in `WebRTCManager` / `WebRTCConnection`, removing the hard-coded disabled observability fallback with an empty API key. - Rename inter-frame delay `Variance` stat to `StdDev` to match the actual computation. - `pnpm --filter @decartai/sdk typecheck` - `pnpm --filter @decartai/sdk format:check` (passes with existing warnings/info) - `pnpm --filter @decartai/sdk test -- --run` - `pnpm --filter @decartai/sdk build` (passes; existing tsdown warning about `define` option) - Independent Claude Code review of diff vs `origin/alon/livekit-pr1-observability` Base for #132. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes realtime telemetry behavior (subscribe path now honors `telemetryEnabled`) and makes `WebRTCManager`/`WebRTCConnection` require an injected `RealtimeObservability`, which can be a breaking change for any consumers constructing these classes directly. Renaming a `WebRTCStats` field also risks downstream type/runtime expectations. > > **Overview** > Realtime subscribe sessions now honor the SDK’s `telemetryEnabled` option and immediately call `observability.sessionStarted(sid)` so telemetry/diagnostics are associated with the session. > > `WebRTCManager` and `WebRTCConnection` no longer create an internal fallback `RealtimeObservability` (previously hard-coded telemetry off with an empty API key); callers must pass `observability` explicitly, and unit tests are updated accordingly. > > In `WebRTCStats`, the inter-frame delay metric is renamed from `interFrameDelayVarianceMs` to `interFrameDelayStdDevMs` to match the actual std-dev calculation. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 16388f0. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
88f9a0f to
0f5169d
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7fad891. Configure here.
0f599c7 to
1bacb33
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
alon/livekit-prodinto reviewable chunks.diagnostics.ts+telemetry-reporter.tsinto a newobservability/folder; deletes rootwebrtc-stats.tsin favor of an expandedobservability/webrtc-stats.ts.RealtimeObservability— a single orchestrator that owns telemetry reporting, stats collection, and diagnostic emission.webrtc-manager.ts+webrtc-connection.tsmigrate onto it.WebRTCStatsgains ~20 standard RTCStats fields (NACK/PLI/FIR counts, jitter buffer averages, simulcast accumulation, remote-inbound, selectedCandidatePairs). Strictly additive — every prior field name is preserved.index.tskeep their original identifiers (only the internal re-export paths change).Why this PR exists in isolation
The thesis is "the new observability abstraction is sound, and aiortc already uses it." A reviewer can validate the abstraction by reading one consumer (aiortc) without needing to also evaluate LiveKit, new transports, or any client-side wiring rewrite. PRs 2 and 3 build on this foundation.
Test plan
pnpm exec tsc --noEmit— clean.pnpm test— 161/161 pass.pnpm exec biome check src/ tests/— clean for changed files.platform.decart.ai/api/v1/telemetry.Note
Medium Risk
Touches realtime connection/reconnect and telemetry/stats plumbing; while largely a refactor, expanded stats parsing and new lifecycle wiring could change when/what events and telemetry are emitted.
Overview
Introduces
RealtimeObservabilityas a single owner for diagnostic emission, telemetry reporting, WebRTC stats polling, and video-stall detection, and rewires realtimeconnect/subscribe,WebRTCManager, andWebRTCConnectionto use it instead of ad-hoc callbacks.Moves diagnostics/telemetry/stats code under
realtime/observability/, addsstatsevents to the subscribe client, and replaces the oldwebrtc-stats.tswith an expanded collector that includes additional RTCStats fields (e.g., jitter-buffer/decode metrics, NACK/PLI/FIR, simulcast-aware outbound aggregation, remote-inbound, and selected ICE candidate pairs) while preserving existing field names and SDK export identifiers.Reviewed by Cursor Bugbot for commit 1bacb33. Bugbot is set up for automated code reviews on this repo. Configure here.