Skip to content

Sampling

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).

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').

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.upgraded
  • browser.error, browser.resource_error, browser.unhandled_rejection, browser.react_error
  • replay.chunk
  • any record with severity ERROR or higher

Session sampling and replay sampling are independent. Session replay has its own mode and sampleRate; see Session replay and the replay configuration.