Immutable solution version
Workflow: trace sampling as a strategy
Complete solution
Sampling as a strategy, not a constant: keep errors at full fidelity, sample traces by route value, and use the sampler callback to make per-request decisions.
Workflow: trace sampling as a strategy
One flat sample rate is a compromise that pleases nobody: too high for hot paths, too low for rare-but-critical ones. Sample by value instead.
The principles
- Errors are always full fidelity. Sampling applies to transactions/traces, never to error events.
- Sample hot low-value traffic near zero: health checks, static assets, polling endpoints.
- Sample rare high-value traffic at 1.0: checkout, payment webhooks, admin actions.
- Keep one baseline rate (0.05-0.2) for everything else so dashboards stay representative.
Implement with the sampler
def traces_sampler(sampling_context):
route = sampling_context.get("transaction_context", {}).get("name", "")
if route.startswith("GET /health"): return 0.0
if "/checkout" in route or "/webhooks/" in route: return 1.0
return 0.1The sampler runs per transaction, so decisions follow the request. Keep it pure and fast: no I/O, no database calls.
Mind the edges
traces_sample_rate=0still continues incoming distributed traces;Nonedisables tracing entirely. Use 0, not None, on services that sit mid-trace.- Profiles sample relative to traces, so changing the trace rate silently changes profile volume too.
- Spike protection drops excess volume per project regardless of your rates; sampling strategy and spike protection are complementary, not substitutes.
Verify
After a week, compare per-route sample counts against traffic: hot paths cheap, critical paths complete, baseline representative. Adjust the sampler when routes change; a renamed endpoint silently falls back to the baseline.
Evidence
Researched against live Sentry docs 2026-09-26. The Python options page (docs.sentry.io/platforms/python/configuration/options/) documents tracessamplerate, tracessampler, the 0-vs-None semantics (0 keeps continuing incoming traces, None disables tracing), and profilessample_rate. The quotas page (docs.sentry.io/pricing/quotas/) documents per-category quotas and spike protection. The Laravel guide warns a trace rate of 1.0 burns quota fast.
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_lbXFSINmQUehf2M3g5mgCQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Workflow: trace sampling as a strategy <span>— Vectle</span></a>