Skip to content

docs(rum): add sampling mechanism and best practices guide - #239

Merged
Fiona2016 merged 2 commits into
mainfrom
docs/rum-sampling-best-practices
Aug 3, 2026
Merged

docs(rum): add sampling mechanism and best practices guide#239
Fiona2016 merged 2 commits into
mainfrom
docs/rum-sampling-best-practices

Conversation

@Fiona2016

Copy link
Copy Markdown
Contributor

Summary

Adds a new RUM best-practices article on sampling, distilled from a customer request: they start with a 20% sampling rate and later need to raise it to 100%, or toggle collection on/off, without shipping a new release.

The article covers:

  • What sampling issessionSampleRate semantics, second-stage sessionReplaySampleRate, and the fact that unsampled sessions report nothing (including errors).
  • How sampling works — four rules: session-level draw, sticky in-session decision (cookie, 15 min / 4 h), probability vs. quota, and init-time freeze.
  • Choosing a sampling rate — per-scenario recommendations.
  • Best practice 1: dynamic adjustment — externalize the rate to the customer's config service, init with cached value + async refresh, and call stopSession() on change so the new rate applies without waiting up to 4 h.
  • Best practice 2: business-defined custom sampling — SDK rate reduced to a 0/100 switch, deterministic hash bucketing by userId (user-stable, monotonic rollout), cohort/incident-mode short-circuit rules, and caveats.
  • Platform support matrix and FAQ.

Changes

  • zh/rum/best-practices/sampling.mdx (source)
  • en/rum/best-practices/sampling.mdx (translation)
  • docs.json — registered under RUM → 最佳实践 / Best practices in both languages

Verification

  • mint broken-links: no broken links found
  • docs.json validated with jq

🤖 Generated with Claude Code

Fiona2016 and others added 2 commits August 2, 2026 20:44
Explain how session sampling works (session-level draw, sticky decision,
probabilistic rate, init-time freeze), how to choose a sampling rate, and
two best practices: dynamically adjustable rates via a customer config
service with stopSession(), and business-defined custom sampling with
deterministic hash bucketing. Bilingual (zh source + en translation),
registered in docs.json navigation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…e to sampling guide

Wrap both best-practice examples in Web/Android/iOS tabs, add an advanced
section for applying a new sampling rate immediately on mobile via
stopInstance() + re-initialize at a quiet lifecycle moment (foreground
transition), with warnings on timing, buffered-data flush, rebuild burden,
and scope of use. Clarify that stopSession() alone cannot apply a new rate
on mobile, and update the platform support matrix accordingly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Fiona2016
Fiona2016 marked this pull request as ready for review August 3, 2026 06:49
@Fiona2016
Fiona2016 merged commit 2ef158f into main Aug 3, 2026
1 check passed
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