Skip to content

✨ [RUM-17561] add execution context tracking for main and renderer processes - #209

Draft
bcaudan wants to merge 5 commits into
bcaudan/schema-updatefrom
bcaudan/execution-context
Draft

✨ [RUM-17561] add execution context tracking for main and renderer processes#209
bcaudan wants to merge 5 commits into
bcaudan/schema-updatefrom
bcaudan/execution-context

Conversation

@bcaudan

@bcaudan bcaudan commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Electron apps run across a main process and one or more renderer processes, but RUM events carry no signal about which OS process instance produced them. That makes it hard to correlate events to a specific process run — especially across crashes/relaunches, or when a single long-lived process spans multiple RUM sessions. This adds execution_context tracking so every RUM event can be attributed to the process instance and session that produced it.

Changes

  • Adds a new execution_context RUM event, scoped to one (process, session) pair: the same OS process across multiple sessions produces multiple execution_context documents, all sharing one stable instance_id (the OS pid) so they can still be correlated to the same process run.
  • Tracks the main process via a session-scoped (fake view, main execution context) pair that's created together on init and on every session renewal, and closed together on session expiry. Renderer windows are tracked independently, one execution context per webContents, rotating on the same session boundaries and ending on real process destruction.
  • Gated behind a new enableExecutionContext configuration flag. When enabled, the main process's real "main process" view is replaced by a lightweight fake view used to carry execution-context tagging, until main-process RUM events no longer need a view at all.
  • Adds unit coverage for both halves' lifecycle and session-boundary rotation, plus e2e coverage for the full lifecycle (init, renderer open/close, session expiry/renewal, cross-tagging) and crash-file replay resolving to the execution context active when the crash actually happened.
  • Adds a secondary renderer window to the playground app for manually exercising renderer-process execution contexts.

Test instructions

  1. In playground/, run yarn dev (the playground's SDK init already sets enableExecutionContext: true).
  2. Click "Stop Session", then click anywhere in the window to generate activity — this renews the session and rotates the main execution context.
  3. Click the button to open the secondary renderer window; confirm it gets its own execution context, and that closing it ends that context cleanly.
  4. Optionally, click "Crash" and let the app relaunch — the resulting error event should resolve to the execution context active when the crash happened, not the relaunched process's new one.

Checklist

  • Tested locally (playground)
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated related documentation.
  • Agentic code review findings addressed or explicitly dismissed.

Pulls in the rum-events-format schema's execution_context type for
main-process events, and threads it through RawRumData so raw
execution_context payloads can be built and validated like every other
RUM event type.
Tracks execution-context lifecycle for both processes: MainProcessContext
owns a session-scoped (fake view, main execution context) pair — created
together on init and on every session renewal, closed together on session
expiry, sharing one instance_id across sessions. ExecutionContextCollection
composes it and independently tracks one execution context per renderer
webContents, rotating on the same two session lifecycle events and ending
on real process destruction. Each class registers its own format hook,
tagging only its own source (main or renderer) from its own state.
… mode

ViewContext now tags main-process events with a fake, execution-context-
carrying view (id/url/is_fake) instead of the real "main process" view
identity when execution-context tracking is enabled, so MainProcessContext
can drive that view's lifecycle instead of ViewCollection.
…t tracking

RumCollection starts MainProcessContext/ExecutionContextCollection instead
of ViewCollection when the flag is on, and RendererPipeline threads each
renderer event's webContentsId through to the RUM format hooks so its
execution context can be resolved.
Adds a secondary renderer window to the playground app for exercising
renderer-process execution contexts manually, and covers the feature
end-to-end: main and renderer execution_context lifecycle, session-scoped
rotation on expiry/renewal, and crash-file replay resolving to the
execution context active when the crash happened.
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