Sampling
Overview
Section titled “Overview”RUM uses head-based session sampling for traces and logs. The decision is made once per session: a sampled session exports everything immediately, an unsampled session does not. The default is sessionSampleRate: 1.0 — every session is sampled. As traffic grows you typically lower it (for example 0.1 for 10% of sessions).
Error-triggered upgrade
Section titled “Error-triggered upgrade”Lowering the rate does not mean losing the broken sessions. With upgradeOnError: true (the default), unsampled sessions still buffer recent activity in memory; the moment an error fires, the session is upgraded to sampled and the buffered context is flushed. So you keep the spend predictable without losing the sessions that actually matter.
The buffer is bounded by preSampleBuffer.maxItems and preSampleBuffer.maxAgeMs — the older of the two limits wins, and items are evicted FIFO. The full table is in the SDK reference.
An upgrade is triggered by the first error log on the session: window.error, unhandledrejection, a React boundary error, captureException, or captureMessage(..., 'fatal').
Always-exported records
Section titled “Always-exported records”Even when a session is unsampled, lifecycle and error log records always export so the backend can still see session boundaries and errors:
session.start,session.end,user.changed,sampling.upgradedbrowser.error,browser.resource_error,browser.unhandled_rejection,browser.react_errorreplay.chunk- any record with severity
ERRORor higher
Replay sampling
Section titled “Replay sampling”Session sampling and replay sampling are independent. Session replay has its own mode and sampleRate; see Session replay and the replay configuration.
Next steps
Section titled “Next steps”- Frontend errors — the error sources that trigger an upgrade
- SDK reference — the full
samplingconfiguration table