Skip to content

feat(browser): OTel logs pipeline, MapleBrowser.logger and per-session trace sampling - #1145

Merged
Makisuo merged 2 commits into
mainfrom
feat/browser-sdk-logs-sampling
Sep 29, 2026
Merged

Makisuo merged 2 commits into
mainfrom
feat/browser-sdk-logs-sampling

fix(browser): keep sampled decisions consistent downstream, never los…

43a9cc9
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review completed Sep 29, 2026 in 10m 36s

Confidence 3/5 · No issues found

Confidence 3/5 · needs attention
quality 100/100 · no findings · tests covered · risk medium · 2/2 new units observable

Warning

This review ended early; what follows is what it established.

Adds an OTel logs pipeline behind MapleBrowser.logger, per-session trace sampling (tracing.sampleRate) with ot=th;rv on sampled roots, and reports a failure inside an unsampled traced() as its own kept error span. No defect found; safe to merge.

  • MapleBrowser.logger queues records and exports them to OTLP /v1/logs
  • SessionSampler decides per session and stamps ot=th;rv on sampled roots
  • traced() reports an unsampled failure through captureException
  • New tracing.sampleRate, clamped by the shared resolveSampleRate
What was checked
  • Weight math: ingest SAMPLE_RATE_EXPR right-pads th to 16 digits, so stripping trailing zeros keeps the weight exact (datasources.ts:150, sampling.ts:46)
  • keepContext only drops an unsampled parent, so a kept error is a weight-1 root (sampling.ts:20, deferred/logs.ts:17)
  • Consent: records dropped at emit and filtered again at export by consentAllowedSince (logs.ts:40, deferred/logs.ts:23)
Observability coverage: 2 of 2 changes observable
Change Kind Observable Evidence
browser logs export (emitLog → OTLP /v1/logs) outbound OTLP HTTP export yes OTLPLogExporter + resourceAttributes(); records carry session.id/user.id and the emitting span's context (deferred/logs.ts:44-68)
per-session trace sampling (SessionSampler) head sampling yes sampled roots set ot=th:…;rv:… and inherit to children, which is what the ingest SampleRate column reads (sampling.ts:85)

43a9cc9 · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple to ask about one.