For self-hosted Flagsmith Experimentation
Can you trust this Flagsmith experiment?
The bridge shows an experiment's health on the Grafana and Prometheus you already run, turns your OpenTelemetry spans into experiment metrics, and ships a doctor command that explains why an experiment is stuck or misleading.
Built for teams that run self-hosted Flagsmith Experimentation (beta) next to an OpenTelemetry, Prometheus and Grafana stack. Without Prometheus and Grafana, doctor still works on its own.
make upNeeds Docker with Compose and about 1.7 GB of free memory. First results take about 7 minutes (6.8, 6.9 and 6.8 min in the last three clean runs), because Flagsmith computes results at most every 5 minutes. Run make check after that.
Three verdicts, 95% intervals
make slow.A bad experiment looks the same as a good one
Picture a results page that says "no effect". Nobody checks whether the metric event name was spelled the same way in the app. The experiment gets closed and the idea gets dropped, while nothing was ever counted.
A mistyped event name
The experiment shows "no effect" when nothing was counted.
An uneven split or the wrong audience
The traffic split is off, or people outside the targeted audience are exposed, so the arms are not comparable.
A slower variant
A new variant makes pages slower, but latency is not one of the experiment's metrics.
Stopping at the first lead
Someone checks every day and stops the first time one arm looks ahead.
One dashboard, one command
Per experiment the dashboard shows link health, results age, SRM p-value, early_stop_risk, data floors and OTLP events. Below that: exposures and conversion rate per arm, chance to win, a 95% interval table, and one verdict per metric.
make slow (900 ms added to variant b); it is not a finding. The screenshot predates 29 Nov, so one panel still carries its old title; the current dashboard calls it "Guardrail harm (1 = variant worse beyond its 95% interval)".[PASS] C-11 No sample ratio mismatch (SRM) evidence: arms {'b': 196, 'control': 193}, p=0.879 (bridge chi-square (Flagsmith returns null)) [WARN] C-13 No audience pollution evidence: audience pro-plan. Of 200 identities sampled from this environment (up to 200, with traits), 125 (62%) are OUTSIDE the audience (e.g. demo-08c508-1, ...). Arms {'b': 196, 'control': 193} vs intended {'b': 50.0, 'control': 50.0} (SRM p=8.8e-01). Arm sizes look fine, so they may never have been exposed; confirm your code does not evaluate the experiment flag for them. fix: Only call get_experiment_flag for identities that match the audience (check the segment in your own code first) and use get_flags/get_identity_flags for everyone else. ... ... == summary == 25 PASS, 1 WARN, 0 FAIL, 1 SKIP across 2 experiment(s) needs attention: pricing-exp C-13 (WARN)
2 of the 27 check lines plus the summary; long lines wrapped and ... marks cuts. The demo plants this mistake on purpose: pricing-exp targets plan == pro, but the simulated app asks for the flag for every visitor.
Spans in, experiment metrics out
OTLP brings conversions and guardrail events only. Exposures (who saw which variant) still come from your app's Flagsmith SDK calls.
- Sidecar receives OTLP/HTTP, maps spans to Flagsmith events with
mappings/default.yaml, delivers them with retries and counts everything it drops. - Exporter reads Flagsmith results every 30 s, adds SRM and
early_stop_risk, and serves Prometheus metrics. - Doctor runs checks C-01 to C-13 against the Flagsmith APIs. Exit code 1 on any FAIL, so it can gate a pipeline.
- Generator is a stand-in app that produces the simulated traffic for the demo.
Five questions it answers
| You want to know | The bridge gives you |
|---|---|
| Did the new variant make pages slower? | Your OTel spans become Flagsmith events, so a latency guardrail metric lives inside the experiment. An alert fires when the 95% interval for the variant lies entirely on the bad side. |
| Is the result real or noise? | Lift with its 95% interval per metric. An interval that crosses zero is shown as INCONCLUSIVE. |
| Is the traffic split what I configured? | A sample-ratio-mismatch (SRM) p-value, computed here because Flagsmith returned null for it in every run we made. If Flagsmith sends a value, the bridge uses it. |
| Am I looking too early? | early_stop_risk, our own estimate of how often an A/A experiment looks decisive by luck when you keep checking. |
| Why is my experiment empty or odd? | doctor: 13 checks. Each prints evidence; every WARN or FAIL also prints a fix. The code refuses to build a WARN or FAIL without one, and a unit test checks this. |
QA and internal traffic stays out: ignore: in the mapping drops spans by identity prefix (qa-, internal- by default) or attribute value, and counts them in bridge_sidecar_events_ignored_total.
Everything depends on Flagsmith
The experiment, its multivariate flag and its arms live in Flagsmith. Each row was checked against the code.
| Flagsmith feature | How the code uses it | Where |
|---|---|---|
| Raw events API | POST /api/v1/events/. OTLP spans become events that experiment metrics count, and rejected is always inspected. | client.py, sidecar.py |
| Experiments | List, read, start (/environments/{key}/experiments/). | client.py, seed.py |
| Results and exposures | Read .../results/ and .../exposures/; refresh by POST on .../results/refresh/ and .../exposures/refresh/. | client.py, exporter.py |
| Experiment metrics | List and create metrics (/experiment-metrics/). | seed.py, doctor.py |
| Warehouse connection | Create one, read stored event names (/warehouse-connections/{id}/events/) for C-03 and C-08. | seed.py, doctor.py |
| Segments, identities, traits | doctor reads the audience segment and up to 200 identities with traits for C-13. | doctor.py |
| Multivariate flags | Seeded as two-option flags with a 50/50 allocation. | seed.py |
Python SDK get_experiment_flag | The demo generator records exposures through it. | generator.py |
| Health endpoint | GET /health for C-01. | client.py, doctor.py |
The 13 doctor checks
- C-01Flagsmith reachable
- C-02Experimentation available and token valid
- C-03Warehouse connection
- C-04Experiment is running
- C-05Variations have keys and none is named "control"
- C-06Allocation and rollout sane
- C-07Exposures are arriving
- C-08Metric event names exist in the warehouse (with did-you-mean)
- C-09Metrics join to exposures
- C-10Metrics above Flagsmith's sample floors
- C-11No sample ratio mismatch (SRM)
- C-12Quarantined identities
- C-13No audience pollution
What was measured, and on what
Every number here comes from local runs on 26 to 29 Nov 2026 with simulated traffic and no real users. The results test the pipeline. They are not evidence about real users.
Pipeline runs
- One OTLP span becomes one accepted event, visible in the Flagsmith warehouse (
make e2e), and aqa-identity is counted as ignored. - 6.8 and 6.9 minutes from a clean start on an empty database to live data (independent runs, 28 and 29 Nov). Prometheus targets up, Grafana healthy.
- Alert fires. With the slow variant injected,
ExperimentVariantHarmsGuardrailreached firing in Prometheus about 6.4 and 6.5 minutes aftermake slow(26, 28 and 29 Nov runs). - Flagsmith outage. Stopped and started again:
bridge_up0 within about 20 s, last results kept, back to 1 about 20 s after restart. - 61 unit tests passed on 29 Nov; the same code then ran live with e2e 3/3 and
doctorexit 0.
How often does an A/A test look decisive by luck?
of 3000 A/A runs look decisive at some look (sim_peeking.py --step 50 --maxn 2000, 10% base rate). This reproduces the 46.0% quoted in the hackathon background material.
The shipped early_stop_risk table: share of A/A runs that were decisive at some look up to n identities per arm (3000 runs, a look every 25 identities per arm, Flagsmith's floors). One table for every metric, based on a 10% base rate.
The demo traffic is simulated by a generator that asks Flagsmith for each visitor's variant through the SDK and acts on the answer. Simulated visitors convert at 10% versus 12.5%, plus 0.5 point for the lower price. That assumption lives in generator.py and is the only thing the experiments can discover.
Limits, stated up front
No real users
All traffic is simulated and nothing was tested at volume.
Shared simulated traffic
Two experiments share the same traffic and the checkout_completed metric. Real experiments are usually independent.
The slow variant is a local switch
make slow writes a file the generator reads. It simulates a slower page and is not a real latency regression.
early_stop_risk is one table
A 10% base rate for every metric. It is our own simulation, not a Flagsmith number. The alert only fires while the smallest arm has fewer than 500 identities.
No multiple-comparison correction
Each metric and variant is judged against its own 95% interval. With k comparisons expect about k x 5% false positives. INTERVAL EXCLUDES 0 is not a frequentist significance test.
Results are up to about 5 minutes old
Flagsmith's refresh cooldown. Self-hosted only; tested on Flagsmith 2.295.2.
Local demo security only
Grafana allows anonymous read-only access, the compose file has default secrets, and the OTLP endpoint is open unless you set SIDECAR_TOKEN. Every port is bound to 127.0.0.1.
No public repo, hosted demo or video
The only live view is the local Docker run. Other entries are far more polished in packaging and test evidence.
Delivery guarantee: the sidecar answers OTLP success when events are in its in-memory queue (20,000 by default). Events are lost if the process dies, and a batch whose response is lost can be delivered twice. Nothing is dropped without a counter.
Try it in about 10 minutes
Needs Docker with Compose and about 1.7 GB of free memory. Everything listens on 127.0.0.1 only. The step-by-step guide is a separate page.
Start the demo stack
make up # = docker compose up -d --build
make check # unit tests, one OTLP span end to end, doctor
# run it about 7 minutes after `make up`
Then open http://localhost:8314 (Grafana, dashboard "Experiment Observability Bridge"). Flagsmith is on http://localhost:8301. Until the first results arrive, Grafana panels are empty and doctor reports C-07 and C-10 as WARN, not FAIL. Port busy? Set GRAFANA_PORT=18314 or another port variable.
Play with it
make slow # variant b of checkout-exp 900 ms slower; guardrail shows harm, alert fires make fast # remove the slowdown make doctor # explain what is wrong with the demo experiments make down # stop and delete all data
Run the tests
make test # 61 unit tests, no Flagsmith needed make e2e # needs the running stack
Use your own Flagsmith and OpenTelemetry
export FLAGSMITH_URL=... FLAGSMITH_TOKEN=... FLAGSMITH_ENV_KEY=... pip install . # bridge-exporter, bridge-sidecar, bridge-doctor
Point an OpenTelemetry Collector at the sidecar with the otlphttp exporter (the example config was tested once, on 26 Nov). See docs/USE-WITH-YOUR-FLAGSMITH.md in the repository.