✨ forward logs from the renderer process - #212
Conversation
5357937 to
02097f5
Compare
There was a problem hiding this comment.
PR Review — Score: 4.8 / 5
This is a well-executed feature PR that closes an important gap: once the Browser Logs SDK is in bridge mode, renderer logs have no other path to Datadog, and this change makes relay reliable end-to-end. The implementation follows established SDK patterns (format hooks, customer-context precedence, mobile WebView parity for logsSampleRate), fixes the init-order race by registering transport before opening the IPC listener, and is backed by thorough unit and e2e coverage including the 1,000-entry intake split. I would approve.
Why 4.8: Correct boundary validation, observable failures via telemetry, monitor() on the IPC path, intentional context-merging rules, unconditional LOGS track registration for recovery, batch rotation at the intake limit, and documentation/README updates that explain the bridge-mode sampling contract clearly.
Why not 5: The top-level monitoring architecture diagram still depicts only RUM over the bridge (logs get a prose section but not a diagram edge), and configuration telemetry has no schema field for logsSampleRate yet so usage of non-default sampling is invisible in SDK configuration events (consistent with existing telemetry constraints, but still a small observability gap).
Findings
- [Nit] Architecture diagram omits logs — The new Logs section is accurate, but the overview Mermaid chart still labels the bridge as RUM-only; a second edge (or relabel) would match the new behavior.
Architectural flow
sequenceDiagram
participant BL as Browser Logs SDK
participant Bridge as DatadogEventBridge
participant RP as RendererPipeline
participant Hooks as Format Hooks
participant EM as EventManager
participant T as Transport LOGS track
participant Intake as Datadog Logs Intake
BL->>Bridge: assembled log event
Bridge->>RP: IPC log message
RP->>RP: validate date message status
RP->>RP: apply logsSampleRate
RP->>Hooks: triggerLogs enrichment
Hooks-->>RP: application session usr account
RP->>EM: ServerLogsEvent on LOGS track
EM->>T: post to batch producer
T->>Intake: POST /api/v2/logs with ddsource=browser
Before: Bridge log events were accepted over IPC but dropped in RendererPipeline (TODO), so renderer logs in bridge mode were lost after the Browser Logs SDK stopped talking to intake directly.
After: Valid logs are sampled via logsSampleRate, enriched with main-process session/application/user/account context while preserving renderer-owned fields (service, ddtags, view, etc.), batched on a dedicated LOGS track (splitting at 1,000 events), and uploaded with ddsource=browser and DD-EVP-ORIGIN: electron. Transport handlers are registered before the IPC listener opens so events cannot fall through an unhandled gap during init().
Sent by Cursor Automation: electron-sdk reviews
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
02097f5 to
626f0d8
Compare
Forward Browser Logs events received over the renderer bridge on a dedicated LOGS track so enabling the bridge no longer drops them. Preserve browser attribution and renderer-owned fields while enriching logs with Electron application, session, user, and account context. Add host-side per-log sampling through logsSampleRate, matching the mobile WebView integrations. Register transport before renderer IPC, split Logs uploads at the 1,000-entry intake limit, align the public payload types and exports, and cover forwarding, sampling, context, and batching with unit and end-to-end tests. Ticket: RUM-15536 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
626f0d8 to
1296494
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1296494983
ℹ️ 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".
| * the main process reads or replaces are named here; everything else the renderer sends is carried | ||
| * through untouched, so a field browser-core adds does not need a change on this side. | ||
| */ | ||
| export interface LogsEvent { |
There was a problem hiding this comment.
Add an example for the exported LogsEvent API
The new LogsEvent type is exported from src/index.ts, making it a public API, but its JSDoc has no @example. docs/REVIEW.md explicitly requires every new or modified public API to include one; add a representative Browser Logs payload example so the generated declarations meet the repository's API documentation standard.
AGENTS.md reference: AGENTS.md:L3-L6
Useful? React with 👍 / 👎.
| Logs assembled by the Browser Logs SDK are forwarded through the Electron bridge and uploaded by the | ||
| main process. Configure renderer-log sampling on the Electron SDK: |
There was a problem hiding this comment.
Document the renderer-side Logs SDK initialization
When a customer follows this new section, it only shows configuring the main-process Electron SDK and never tells them to install and initialize @datadog/browser-logs. The preceding setup link is specifically for Browser RUM, and logsSampleRate alone cannot produce renderer log events, so the advertised feature silently sends nothing unless users infer this separate step; include the renderer-side Browser Logs setup or a direct link to it.
AGENTS.md reference: AGENTS.md:L3-L6
Useful? React with 👍 / 👎.


Motivation
The Electron bridge already receives
logevents from the renderer Browser Logs SDK, butRendererPipelinediscarded them. In bridge mode the Browser SDK sends logs only to the host, so installing the Electron SDK alongside@datadog/browser-logscould silently lose every renderer log.Ticket: RUM-15536
Changes
Forward and enrich renderer logs
ServerLogsEventobjects on a dedicated LOGS track.date,message,status,service,ddtags, view, and action context.ddsource=browserwhile retainingDD-EVP-ORIGIN: electronfor the uploader identity.Sample logs in the host SDK
Browser Logs uses an always-tracked session stub in bridge mode, so renderer
DD_LOGS.init({ sessionSampleRate })does not sample logs sent over the bridge. This addslogsSampleRateto Electron SDK configuration:0–100and defaults to100;sessionSampleRate;Close reliability and API gaps
LogsAssembleParamsfrom the assembly barrel.README.md, and keep the architecture overview concise.Verification
yarn typecheck yarn test:unit yarn test:e2e:init yarn playwright test -c e2e --project=e2e e2e/scenarios/logs.scenario.tslogsSampleRate: 0and a 1,001-log upload split into requests of 1,000 and 1.git diff --checkpassed for the changed files.Checklist