Datadog feature flags offer a powerful, integrated way to manage feature delivery, with built-in observability and seamless integration across the platform.
Real-time metrics: Understand who’s receiving each variant, as well as how your flag impacts the health & performance of your application—all in real time.
Supports common flag types: Use Boolean, string, integer, numeric (float/double), or JSON variants. JavaScript SDKs use getNumberValue() for both integer and numeric variants, while Java, Swift, Kotlin, and Python expose separate integer and floating-point evaluation methods.
Built for experimentation: Target specific audiences for A/B tests, roll out features gradually with canary releases, and automatically roll back when regressions are detected.
OpenFeature compatible: Built on the OpenFeature standard, ensuring compatibility with existing OpenFeature implementations and providing a vendor-neutral approach to feature flag management.
Feature Flags SDKs
This guide uses the JavaScript browser SDK as an example. You can integrate Datadog Feature Flags into any application using one of the following SDKs:
Client-side SDKs
Server-side SDKs
Configure your environments
Your organization likely already has pre-configured environments for Development, Staging, and Production. For details on environment queries, production marking, and managing environments, see Environments.
Create your first feature flag
Step 1: Import and initialize the SDK
Choose the SDK that matches where the flag is evaluated and initialize the Datadog Feature Flags provider.
Install @datadog/openfeature-browser, @openfeature/web-sdk, and @openfeature/core as dependencies in your project:
Then, add the following to your project to initialize the SDK:
Browser Feature Flags are not supported for the selected Datadog site ().
import{DatadogProvider}from'@datadog/openfeature-browser';import{OpenFeature}from'@openfeature/web-sdk';// Initialize the provider
constprovider=newDatadogProvider({// Required client-side Datadog credentials
applicationId:'<APPLICATION_ID>',clientToken:'<CLIENT_TOKEN>',site:'<code class="js-region-param region-param" data-region-param="dd_site"></code>',env:'<YOUR_ENV>',// Same environment normally passed to the RUM SDK
service:'<SERVICE_NAME>',version:'1.0.0'});// Set the provider
awaitOpenFeature.setProviderAndWait(provider);
The browser SDK emits three independent telemetry streams, all enabled by default. enableExposureLogging sends per-evaluation exposure events to the exposures intake. enableFlagEvaluationTracking sends aggregated evaluation telemetry to the flag-evaluation intake. enableRumFeatureFlagTracking attaches flag evaluations to RUM events and is the setting that can affect RUM usage. Disable only the stream you do not need.
Install dd-trace and the OpenFeature server SDK:
npm install dd-trace @openfeature/server-sdk
Enable the provider with environment variables:
# Required: Enable the feature flags providerDD_EXPERIMENTAL_FLAGGING_PROVIDER_ENABLED=true# Optional: Enable flag evaluation metricsDD_METRICS_OTEL_ENABLED=true
Add the OpenFeature SDK and Datadog OpenFeature provider dependencies:
build.gradle
dependencies{// OpenFeature SDK for flag evaluation
implementation'dev.openfeature:sdk:1.18.2'// Datadog OpenFeature Provider
implementation'com.datadoghq:dd-openfeature:1.57.0'}
Enable the provider and start your application with the Java tracer:
# Required: Enable the feature flagging provider# The EXPERIMENTAL_ prefix is historical; the provider is no longer experimental.exportDD_EXPERIMENTAL_FLAGGING_PROVIDER_ENABLED=true# Optional: Enable flag evaluation metricsexportDD_METRICS_OTEL_ENABLED=truejava -javaagent:path/to/dd-java-agent.jar -jar your-application.jar
# Required: Enable the feature flags providerexportDD_EXPERIMENTAL_FLAGGING_PROVIDER_ENABLED=true# Optional: Enable flag evaluation metricsexportDD_METRICS_OTEL_ENABLED=true
Install the Datadog Python SDK and OpenFeature SDK:
pip install ddtrace openfeature-sdk
Register the Datadog OpenFeature provider:
fromddtraceimporttracerfromopenfeatureimportapifromddtrace.openfeatureimportDataDogProvider# Initialize the tracer (required for Remote Configuration)tracer.configure()# Create and register the Datadog providerprovider=DataDogProvider()api.set_provider(provider)# Create an OpenFeature clientclient=api.get_client()
Credentials at a glance
Credential
Used by
Where it goes
Sensitive?
Client token
Browser, mobile, and game SDKs
Client application configuration
No — safe to ship in public client code
Application ID
Browser and RUM-backed client SDKs
Client application configuration
No — public identifier
API key
Datadog Agent for server-side Remote Configuration
Agent configuration only
Yes — keep server-side only
Do not put API keys in browser, mobile, or game applications.
More information about OpenFeature SDK configuration options can be found in its documentation. For more information on creating client tokens and application IDs, see API and Application Keys.
Flag keys, variant keys, and variant values should be considered public when sent to client SDKs.
Step 3: Evaluate the flag and write feature code
In your application code, use the SDK to evaluate the flag and gate the new feature.
Datadog Feature Flags requires evaluation context attributes to be flat primitive values: strings, numbers, and Booleans. Do not pass nested objects or arrays; they are not supported and can cause exposure data to be dropped.
import{OpenFeature}from'@openfeature/web-sdk';constclient=OpenFeature.getClient();// If applicable, set relevant attributes on the client's global context
// (e.g. org id, user email)
awaitOpenFeature.setContext({org_id:2,user_id:'user-123',email:'user@example.com',targetingKey:'user-123'});// This is what the SDK returns if the flag is disabled in
// the current environment
constfallback=false;constshowFeature=awaitclient.getBooleanValue('show-new-feature',fallback);if(showFeature){// Feature code here
}
constevaluationContext={targetingKey:req.session?.userID??'unknown',companyID:req.session?.companyID};constisNewCheckoutEnabled=awaitclient.getBooleanValue('new-checkout-flow',// flag key
false,// default value
evaluationContext,// context
);if(isNewCheckoutEnabled){showNewCheckoutFlow();}else{showLegacyCheckout();}
importdev.openfeature.sdk.EvaluationContext;importdev.openfeature.sdk.MutableContext;EvaluationContextcontext=newMutableContext("user-123").add("email","user@example.com").add("tier","premium");booleanenabled=client.getBooleanValue("checkout.new",false,context);if(enabled){// New checkout flow}else{// Old checkout flow}
After you’ve completed this step, redeploy the application to pick up these changes. Additional usage examples can be found in the platform-specific SDK pages linked above.
Step 4: Define targeting rules and enable the feature flag
Configure targeting rules to define which subjects receive each variant. After saving your rules, enable the flag in your chosen environment.
As a general best practice, roll out changes in a Staging environment before Production.
Monitor the feature rollout from the feature flag details page, which provides real-time exposure tracking and metrics such as error rate and page load time. As you incrementally release the feature with the flag, view the Real-Time Metric Overview panel in the Datadog UI to see how the feature impacts application performance.