OTel: Sampling support

Open
#190 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
observability

Research direction

Read the OTel integration described in #189 and inspect how the BatchSpanProcessor and OTEL_TRACING_EXCLUDED_URL_PATHS are configured. Compare the collector-side and SDK-side options in this issue, then confirm the production sampling approach and its configuration or documentation. Done means the chosen approach is agreed and its required project changes are complete.

Written by the indexing model from the issue text.

Description

Currently, the OTel integration (#189) uses the default ParentBasedAlwaysOn sampler — 100% of traces are captured. This is fine for initial rollout but we should add configurable sampling for production use.

Options to consider

  1. Collector-side tail-based sampling — keep errors and slow requests, drop routine 200s. No code changes needed, just collector config. This should be the first approach, and implies no code changes.
  2. SDK-side head sampling — e.g. TraceIdRatioBased(0.1) for 10% sampling. Reduces overhead on the API process. Useful at very high request volumes.
  3. Per-route sampling — different rates for different endpoints (e.g. 100% for webhooks, 1% for feature flags evaluation).

Context

  • The BatchSpanProcessor is lightweight, so SDK-side sampling is unlikely to be needed until high request volumes.
  • Health/readiness endpoints are already excluded via OTEL_TRACING_EXCLUDED_URL_PATHS.
  • This is also relevant for eventually replacing Sentry SDK tracing with OTel-native tracing.

Related: #182

Dominant language
Python
Stars
2
Forks
4
Avg merge
2d 9h
Merged PRs (30d)
10

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Flagsmith/flagsmith-common

All issues in Flagsmith/flagsmith-common

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.