OpenTelemetry Feature Flags: Put Flag Reads on Your Traces

Record which variation each request got on OpenTelemetry traces, attach flags to Sentry errors, and draw flag changes on Grafana and Datadog dashboards.

  • observability
  • opentelemetry
  • sdks

Here’s an afternoon we made up, though plenty of on-call engineers have lived some version of it. At 14:12 the checkout latency alert fires. p95 was 380 ms an hour ago and it’s 1.4 seconds now. The engineer on call opens a slow trace and finds the usual spans: the HTTP handler, two database queries, a call to the payments service. The screen is silent about the 14:05 bump of new-checkout from 25% to 50%, and about whether this request was on the new path at all.

Which variation served the slow requests? Did a flag change right before they started? Those are what the engineer needs in the first ten minutes, and a default OpenTelemetry setup can’t say.

Key Takeaways

  • A flag read makes no span, so a trace says nothing about flags until you add the evaluation to the active span yourself.
  • OpenTelemetry names the event feature_flag.evaluation and its attributes (feature_flag.key, feature_flag.result.variant, feature_flag.result.reason). The event is at Release Candidate status.
  • Flag changes belong on your dashboards as Grafana annotations or Datadog change events, so a latency step lines up with the change that came before it.
  • Traces are sampled. For how often each variation was served, read evaluation counts.

1. Why your traces say nothing about flags

Auto-instrumentation wraps work that has a start and an end and usually crosses a process boundary: an inbound request, a SQL query, an outbound HTTP call. A local flag read crosses nothing. A server SDK that evaluates locally looks the rule up in memory, runs it against the context you passed and hands back a value, all inside the function call your code made, so an instrumentation library never gets a chance to wrap it.

The change is invisible from the other direction. It happened in the flag platform, and the record of who raised new-checkout to 50% sits in that platform’s audit log while the latency graph lives in Grafana or Datadog, in another tab. Until something copies the change onto the graph, the person staring at it has to think to go and check, and at 14:12 with a page open most people don’t.

A trace only describes one request, so how often each variation was served, and by which rule, has to come from totals.

2. What the OpenTelemetry feature flag conventions define

OpenTelemetry’s semantic conventions include a feature flag evaluation event. The event is named feature_flag.evaluation and is at Release Candidate status, inside a document that is still marked Development as a whole. These are its attributes, with the requirement level the spec gives each one:

AttributeRequirement levelWhat it holds
feature_flag.keyRequiredThe flag key
feature_flag.result.variantConditionally required, when the provider has variantsThe served variation
feature_flag.result.valueConditionally required only when there’s no variant, opt-in otherwiseThe evaluated value
feature_flag.result.reasonRecommendedWhy that value was served
feature_flag.provider.nameRecommendedWhich flag system answered
feature_flag.context.idRecommendedThe targeting key, usually a user id
feature_flag.set.id, feature_flag.versionRecommendedThe flag set and its version
error.typeConditionally required, on errorsWhat went wrong

The reason has a fixed list of well-known values: cached, default, disabled, error, split, stale, static, targeting_match and unknown. If one of them fits, the spec says you must use it. Map your platform’s own reasons onto that list and every dashboard you build can filter on the same words, whatever SDK wrote the event.

The spec says evaluations SHOULD be recorded as attributes on an event passed to a Logger, which is the log-based kind of event, and it notes those aren’t available yet in some languages. Separately, OpenTelemetry is deprecating the span event API, Span.AddEvent included, in favor of the same log-based events. The same post says existing span events and the views that show them keep working.

We record span events today anyway. Grafana Tempo and Jaeger draw them on the span you already have open, and that’s where the on-call engineer is looking. The attribute names are identical in both forms, so a later switch touches the one call that writes the event and nothing downstream.

3. Put the evaluation on the span

Featureflip’s server SDKs accept inspectors, plain functions the SDK calls on every evaluation with the flag key, the variation, the reason and the rule that matched. An inspector that writes feature_flag.evaluation onto the active span takes under twenty lines. This is the Node.js one, trimmed. The full versions in the analytics integration guide also map errors to error with an error.type, and cover Python, Java and C# too:

import { trace } from '@opentelemetry/api'
const REASONS = {
RuleMatch: 'targeting_match',
Fallthrough: 'default',
FlagDisabled: 'disabled',
PrerequisiteFailed: 'prerequisite_failed',
}
function recordFlagEvaluation(event) {
const span = trace.getActiveSpan()
if (!span?.isRecording()) return
span.addEvent('feature_flag.evaluation', {
'feature_flag.key': event.flagKey,
'feature_flag.provider.name': 'featureflip',
'feature_flag.result.reason': REASONS[event.reason] ?? 'unknown',
...(event.variationKey && { 'feature_flag.result.variant': event.variationKey }),
})
}

Pass it as inspectors: [recordFlagEvaluation] when you create the client. Outside a recording span it returns before it allocates anything. It makes no network call either, since the event rides out with its span through the batching exporter you already run.

prerequisite_failed is a custom reason. The spec allows one when none of the well-known values fit, and a flag that served its off value because another flag wasn’t on is worth telling apart from a plain disabled during an incident.

The recipe leaves out feature_flag.context.id and feature_flag.result.value on purpose, since the first is usually a user id and a JSON flag’s value can hold whatever someone put in it. Add either one only if your traces are allowed to carry personal data.

Go’s variation methods take no context.Context, so an inspector can’t find the active span. There, use the Featureflip OpenFeature provider with OpenFeature’s own OpenTelemetry tracing hook, which reads the span from the ctx you pass. That hook always adds the context id and the value, so strip them in your collector if they count as personal data for you.

We run the C# version in Featureflip’s own Management API, so our flag reads show up in Grafana Tempo next to everything else. Two queries do most of the work. The first finds slow requests that got one variation:

{ event.feature_flag.key = "new-checkout" && event.feature_flag.result.variant = "true" && duration > 1s }

The second charts p95 per variation, using TraceQL metrics:

{ event.feature_flag.key = "new-checkout" } | quantile_over_time(duration, .95) by (event.feature_flag.result.variant)

We ran both against our own traces before putting them here, with one of our real flag keys in place of new-checkout. The duration in each is the duration of the span that carries the event. If your code reads the flag inside the request handler, that’s the request. If it reads the flag inside a child span, the number describes the child.

4. Put the flags on the error report

Sentry can list the flags a request evaluated before it failed, right on the error event. Its docs say it keeps “the 100 most recently evaluated flags leading up to the error”. Booleans only, for now. That covers most release flags anyway.

Python, Java and browser JavaScript go through Sentry’s OpenFeature integration and the matching Featureflip OpenFeature provider, which means no Featureflip-specific code at all. Node.js is different, because Sentry has no OpenFeature integration there, so an inspector calls addFeatureFlag(key, value) on Sentry’s featureFlagsIntegration() for every boolean read. Keep a reference to the integration. The method lives on it, and the flags go on the current scope, which keeps them apart per request only while Sentry’s request isolation is running.

Go and .NET are the gap. As of November 2026, Sentry’s SDKs for both have no feature flag API, so put the evaluation on the trace with the OpenTelemetry recipe and follow the trace from the error.

5. Put flag changes on the dashboard

A flag change is an event with a timestamp, and both big dashboard tools already know how to draw one.

Featureflip’s webhooks have Grafana and Datadog as built-in destinations, on every plan. For Grafana, each change becomes an organization annotation tagged featureflip, flag:<key>, env:<environment> and project:<project>. Add an annotation query to a dashboard on the Grafana data source, filtered by the featureflip tag, and every flag change appears as a vertical line on every panel. Too much staging noise? Add env:production as a second tag.

For Datadog, each change arrives through the Events API as a change event. Flag events are recorded as a feature_flag change named after the flag key, which is what Datadog’s Change Tracking reads, so the toggle lands on the same timeline as your deploys. Both destinations tag by flag key, so renaming a flag doesn’t split its history.

Checkout p95 latency per variation, with the flag change drawn as an annotation An illustrative chart from 13:30 to 14:30. Before 14:05 one line sits near 380 milliseconds. A dashed vertical annotation at 14:05 reads new-checkout 25% to 50%. After it the line splits by variation: requests on the false variation stay near 390 milliseconds while requests on the true variation climb to about 1.4 seconds. 0 400 ms 800 ms 1.2 s 1.6 s 13:30 13:50 14:05 14:20 14:30 new-checkout 25% to 50% (Grafana annotation from the webhook) variant "true": ~1.4 s variant "false": ~390 ms p95 before the change: ~380 ms
Illustrative numbers. The annotation marks the flag change. Splitting p95 by feature_flag.result.variant shows the slow requests were the ones on the new path.

The same alert can also act on the flag. A flag trigger is a URL that turns one flag off when your alerting calls it, and we wrote up which alerts deserve one, from the alert’s side of the wire.

6. Count what the flag served

If you sample traces, keeping 10% or 1% of requests or keeping errors and dropping the rest, an evaluation event lives or dies with its span. A count of traces per variation then describes your sampler’s choices as much as your users.

For totals, use the evaluation counts your SDKs already send. Every Featureflip flag has an Analytics tab that shows, per environment and for 7, 30 or 90 days, how many evaluations each variation got and which rule, rollout, default or off variation served them. Under each percentage rollout sits a sample-ratio check. It compares the configured split with what was served and warns only when the gap is that unlikely by chance and some variation is at least 2 points off its weight.

Check it before blaming the code. In the made-up incident, suppose the rollout says 50% but the “true” variation served 70% of evaluations. Usually that means something reads the flag twice on the new path, and the slow requests may be paying for that extra work.

The project Dashboard has the cross-flag view: the ten busiest flags, flags that are on but got no evaluations, and every rule between 1% and 99% with its last percentage change from the audit log. The same per-flag numbers are on the Management API and on the MCP server’s flag_evaluations tool. An agent can ask whether the rollout is serving the split it’s set to before anyone widens it.

7. The same afternoon, with all three in place

Back to 14:12. On the latency panel a blue annotation sits at 14:05, labeled new-checkout, seven minutes before the alert fired. The engineer runs the TraceQL metrics query and gets 1.4 seconds at p95 for variant “true” against 390 ms for “false”, and a slow trace picked at random carries a feature_flag.evaluation event with feature_flag.result.variant set to “true”. Sentry’s errors from the same window list new-checkout: true. The Analytics tab shows the rollout serving close to 50%, which rules out a skewed split.

They turn the flag off. Latency drops back within a minute or two, and the postmortem draft already has the trace ID and a screenshot of the annotation pasted into it.

8. What to keep out of flag telemetry

Personal data. feature_flag.context.id and feature_flag.result.value are the two attributes most likely to carry it, so leave them off by default and drop them in the collector for any hook that adds them.

Network calls. An inspector runs synchronously inside every flag read. A request per evaluation adds its latency to every read in your app. Hand the event to something that batches: a span, an analytics SDK’s queue, Sentry’s scope.

Flag variants as metric labels. Putting every flag’s variant on your request duration histogram multiplies its series by every flag and every variation, and many metric backends bill by the series. Traces carry high-cardinality attributes cheaply. Keep the per-variant breakdown there, or label one histogram with one flag for the length of one rollout and remove it afterwards.

Reads your code didn’t act on. Featureflip’s client SDKs deliberately don’t fire inspectors for diagnostic snapshot reads such as flagDetail(), so a debug panel listing every flag doesn’t fill your traces with evaluations that never changed what a user saw.

The shorter version

Write a feature_flag.evaluation span event from an inspector with the key, the variant and the reason, and leave the user id off unless you’re allowed to store it. Send flag changes to Grafana or Datadog. When the page comes, check the evaluation counts on the flag’s Analytics tab before trusting any per-variant trace count. Every language’s recipe is in the analytics integration guide.

Frequently asked questions

What are the OpenTelemetry semantic conventions for feature flags?

They define an event named feature_flag.evaluation, currently at Release Candidate status. feature_flag.key is required. feature_flag.result.variant is conditionally required when the provider has variants. The reason, the provider name and the context id are recommended, and the reason has a list of well-known values such as targeting_match, default, disabled, split and error.

Should feature flag evaluations be span events or log events?

The spec says log-based events, and OpenTelemetry is deprecating the span event API in favor of them. Span events still work, and trace views such as Grafana Tempo and Jaeger show them on the span today, which is why many teams use them for now. Only the recording call changes if you switch later. The attribute names are identical.

How do I see which feature flags were on when an error happened in Sentry?

Use Sentry’s feature flag support. It records up to 100 recently evaluated boolean flags on each error event, and Python, Java and browser JavaScript can feed it through Sentry’s OpenFeature integration with a flag provider. In Node.js, call addFeatureFlag on featureFlagsIntegration() from an SDK hook that runs on every evaluation.

How do I show feature flag changes on a Grafana dashboard?

Send each change to Grafana’s annotations API as an organization annotation with tags such as the flag key and environment, then add an annotation query on the Grafana data source filtered by those tags. Featureflip’s webhooks do the sending as a built-in Grafana destination, so there’s no relay to write.

Does recording flag evaluations on traces slow down my app?

Barely, if the recorder stays in memory. The inspector adds one event to a span that is already being recorded and returns immediately when there’s no recording span. The event leaves with its span through the exporter’s normal batch. An inspector that makes a network call per evaluation would slow every flag read, so keep that kind of work off the hot path.


Featureflip is a flat-priced feature flag platform with evaluation inspectors in its server and client SDKs, webhooks to Grafana, Datadog and Slack, per-variation evaluation analytics on every plan, and flag triggers from the Team plan up. Start on the Free plan without a credit card, then copy the OpenTelemetry recipe for your language from the analytics integration guide.