Repository navigation
Stamp the browser session ID and name onto telemetry events - #456
Merged
Merged
Conversation
Accept a browser_session {id, name} block on PUT/PATCH /telemetry and stamp
each non-empty field onto every published event's source metadata as
session_id / session_name. OTLP export passes metadata through, so exported
log records carry kernel.session_id and kernel.session_name.
The identity is per-event rather than an OTLP resource attribute because a
pooled instance serves more than one browser session; a reconfigure switches
the stamp for subsequent events. publishLocked now stamps a copy of the
producer's metadata map, so an envelope already on the bus keeps the identity
it was published under.
sjmiller609
approved these changes
Oct 14, 2026
Regenerate lib/oapi/oapi.go from the merged openapi.yaml.
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
Browser telemetry exported over OTLP carries
kernel.telemetry_session_idandkernel.instance_name, but neither appears anywhere in the public browser API, so exported records can't be joined back to the browser session that produced them.This lets the control plane tell the instance which browser session owns the capture, and stamps that identity onto every event:
PUT/PATCH /telemetryaccept a new optionalbrowser_session: {id, name}block (echoed inTelemetryState.config).TelemetrySessionstamps each non-empty field intosource.metadataassession_id/session_name, next totelemetry_session_id. The OTLP converter already passes metadata through underkernel., so exported log records now carrykernel.session_idandkernel.session_name. The live stream and S2 storage pick them up too.""clears it. A PATCH that carries onlybrowser_sessionupdates the identity without touching capture. The control plane uses this to keep the name current after a rename.Metadata copy in
publishLockedpublishLockedused to writetelemetry_session_idinto the producer's metadata map in place. The CDP monitor reuses onenavMetamap across events, so a stamp written after a reconfigure would also rewrite envelopes already in the ring or in flight to the exporter. With a per-lease browser session ID, that would mislabel earlier events. The stamps now go on a copy of the map, so an envelope keeps the identity it was published under.Compatibility
session_id/session_namestamps./telemetrydecodes withoutDisallowUnknownFields, so older images ignore the block when a newer control plane sends it.Tests
go test -race $(go list ./... | grep -v /e2e$)passes.go vet ./...is clean.lib/telemetry: identity stamped on every event. Unset fields are omitted. A reconfigure for a new browser session stamps the new ID while the telemetry session ID stays the same. An earlier envelope that shares the producer's metadata map keeps its original identity, and the producer map is not mutated. A new session after a stop carries only its own identity.cmd/api/api: PUT stamps and echoes the identity. A PUT on a running session switches to the new browser session. A PUT without the block clears it. A PATCH merges per field, leaves categories alone, and an empty name clears.lib/events:session_id/session_namemetadata maps tokernel.session_id/kernel.session_nameon the OTLP record.E2E tests were not run (they need Docker images).
Note
Medium Risk
Changes telemetry API semantics and event metadata stamping on a hot path; incorrect copy/merge behavior could mislabel exported records, though tests cover PUT/PATCH and reconfigure cases.
Overview
Adds optional
browser_session: {id, name}onPUT/PATCH /telemetryso the control plane can tag which browser session owns a capture. Non-empty fields are echoed inTelemetryState.configand stamped on every published event assession_id/session_nameinsource.metadata(alongsidetelemetry_session_id), so the live stream, S2 storage, and OTLP export exposekernel.session_idandkernel.session_name.PUT replaces the identity wholesale (omitted block clears it); PATCH merges per field without touching categories, and a PATCH that only sets
browser_sessionskips reconcile.publishLockednow clones producer metadata before stamping so reused maps and in-flight events keep the identity they had at publish time after reconfigure or lease switches on pooled instances.Reviewed by Cursor Bugbot for commit ccb0932. Bugbot is set up for automated code reviews on this repo. Configure here.