This product is not supported for your selected
Datadog site. (
).
A kill switch is a Boolean feature flag where the default state is on (true). The feature runs normally until you enact the kill switch by adding a targeting rule that serves false.
Use a kill switch when you need to turn off risky or broken functionality by using Datadog, without waiting for a deploy. During incidents, that gives operations and engineering a fast path to stop customer impact while the rest of the application keeps running.
Set up a kill switch
Step 1: Create a Boolean flag
Navigate to Create Feature Flag.
Set the variant type to Boolean.
Mark the flag as Permanent.
In the Variants section, click Make Default next to the True variant. This sets true as the value served to all subjects by default.
Save the flag.
Step 2: Evaluate the flag in your application
Wrap the feature code with a Boolean evaluation and a fallback of true. The fallback keeps the feature enabled if the flag configuration is unavailable:
import { OpenFeature } from '@openfeature/web-sdk';
const client = OpenFeature.getClient();
const fallback = true;
const showFeature = await client.getBooleanValue('my-kill-switch-flag', fallback);
if (showFeature) {
// Feature code here
}
enabled = client.get_boolean_value("my-kill-switch-flag", True, eval_ctx)
if enabled:
# Feature code here
pass
enabled, _ := client.BooleanValue(ctx, "my-kill-switch-flag", true, evalCtx)
if enabled {
// Feature code here
}
Deploy the application with the flag check in place before enabling the flag in production.
Step 3: Enable the flag
Enable the flag in the target environment. No targeting rules are needed at this stage — the flag serves true (feature on) to all subjects by default.
Step 4: Enact the kill switch
When you need to disable the feature — for example, during a regression or to stop a third-party integration from sending requests — add a targeting rule that serves false:
- Navigate to the flag in Datadog.
- Add a targeting rule to serve
false to the affected subjects. - Save the rule. The SDK serves
false on the next configuration refresh, and the feature code path stops running for the affected subjects.
Best practices
- Use a fallback of
true so the feature stays enabled if the flag is unavailable — you don’t want the feature to accidentally turn off due to a connectivity issue. - Mark the flag as Permanent. Kill switches are intended to be long-lived, and marking them permanent prevents them from being flagged as stale.
- Test the kill switch in staging before relying on it in production.
- Use evaluation tracking to confirm the flag state during an incident.
Further reading
Additional helpful documentation, links, and articles: