From 6319bd2963e80b3cf264a234574a1c1f6148418e Mon Sep 17 00:00:00 2001 From: Artur Shiriev Date: Fri, 16 Oct 2026 11:04:04 +0300 Subject: [PATCH] docs: recommend trace sampling in production --- readme.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/readme.md b/readme.md index ddf8060..85e2ccb 100644 --- a/readme.md +++ b/readme.md @@ -31,6 +31,16 @@ Authentication is intentionally omitted: pick the scheme that fits your project just --list ``` +## Tracing in production +Setting `OPENTELEMETRY_ENDPOINT` turns tracing on, and by default every request is traced. In a benchmark of `GET /api/decks/{id}/`, that cut throughput by about 40%. Sampling with the standard OpenTelemetry variables brings that down to about 20%: + +```bash +OTEL_TRACES_SAMPLER=parentbased_traceidratio +OTEL_TRACES_SAMPLER_ARG=0.1 +``` + +This keeps one trace in ten, and follows the caller's decision when a request arrives with a trace context. Errors still reach Sentry when `SENTRY_DSN` is set. + ## 📝 [License](https://github.com/modern-python/fastapi-sqlalchemy-template/blob/main/LICENSE) ## Part of `modern-python`