com.datadoghq:dd-openfeature is the Datadog Feature Flags SDK for the OpenFeature Java API.
It evaluates flags locally from the Universal Flag Configuration (UFC) and reports exposures and evaluation counts to Datadog.
The SDK works on its own. When the Datadog Java agent (dd-java-agent) is attached, the SDK also connects to it to use Remote Configuration, the Datadog Agent event proxy, agent telemetry, and APM span enrichment.
- Java 11 or later
- A Datadog API key and site configured in the application for Datadog-managed CDN configuration or direct event intake.
With
remote_configand event delivery through a Datadog Agent, configure them on the Agent instead. - Optionally,
dd-java-agent1.69.0 or later
Add the dependency. It brings the OpenFeature SDK 1.23.0, the OpenTelemetry API and jackson-core:
<dependency>
<groupId>com.datadoghq</groupId>
<artifactId>dd-openfeature</artifactId>
<version>${dd-openfeature.version}</version>
</dependency>Register the provider:
import com.datadog.openfeature.Provider;
import dev.openfeature.sdk.Client;
import dev.openfeature.sdk.OpenFeatureAPI;
OpenFeatureAPI.getInstance().setProviderAndWait(new Provider());
Client client = OpenFeatureAPI.getInstance().getClient();new Provider(new Provider.Options().initTimeout(10, SECONDS)) changes how long initialization waits for the first flag configuration (30 seconds by default).
The provider sends exposures from an OpenFeature provider hook. If you wrap it in OpenFeature's MultiProvider, use dev.openfeature:sdk 1.23.0 or later: earlier versions do not run the hooks of the providers inside a MultiProvider, so the provider sends no exposures there.
Settings are read from the Datadog Java agent configuration when attached, then from dd.-prefixed system properties, then from environment variables.
| Environment variable | Default | Description |
|---|---|---|
DD_FEATURE_FLAGS_ENABLED |
true |
Enables Feature Flags. false makes the provider fail initialization, so evaluations return defaults. |
DD_FEATURE_FLAGS_CONFIGURATION_SOURCE |
agentless |
agentless polls the configuration from the Datadog CDN; without DD_API_KEY or a custom endpoint, the provider fails initialization, so evaluations return defaults. remote_config receives it through Remote Configuration and requires dd-java-agent. |
DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL |
Custom configuration endpoint, such as a proxy. A URL without a path gets the default path. Configuration requests omit the DD-API-KEY header, even when DD_API_KEY is set. A proxy can supply the key, so the application needs none for configuration loading. |
|
DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_POLL_INTERVAL_SECONDS |
30 |
CDN poll interval. |
DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_REQUEST_TIMEOUT_SECONDS |
5 |
CDN request timeout. |
DD_FLAGGING_EVALUATION_COUNTS_ENABLED |
true |
Sends aggregated flag evaluation counts. |
DD_FEATURE_FLAGS_EXPOSURES_DATADOG_LOGGING_ENABLED |
true |
Sends exposures to Datadog. See Stop sending exposures to Datadog. |
DD_FEATURE_FLAGS_EXPERIMENTATION_OPT_OUT_MODE |
disabled |
Controls per-subject experimentation opt-out: disabled, immediate, or future_experiments_only. See Per-subject experimentation opt-out. |
DD_FEATURE_FLAGS_EVALUATION_TELEMETRY_PER_SUBJECT_OPT_OUT_ENABLED |
false |
Lets the dd_evaluation_telemetry_opt_out context attribute opt subjects out of evaluation telemetry. See Per-subject evaluation telemetry opt-out. |
DD_EXPERIMENTAL_FLAGGING_PROVIDER_SPAN_ENRICHMENT_ENABLED |
false |
Adds flag evaluations to the local root span. Requires dd-java-agent. |
DD_API_KEY, DD_SITE, DD_ENV, DD_SERVICE, DD_VERSION |
Credentials and event context. | |
DD_EXPERIMENTAL_FLAGGING_PROVIDER_ENABLED |
Deprecated: true selects remote_config, false disables Feature Flags. An explicit source wins. |
| Feature | SDK only | SDK + dd-java-agent |
|---|---|---|
Configuration, agentless source |
CDN | CDN |
Configuration, remote_config source |
Not supported | Remote Configuration |
| Exposures and evaluation counts | Direct intake, requires DD_API_KEY |
Datadog Agent event proxy, with direct intake fallback in agentless mode |
feature_flag.evaluations OpenTelemetry metric |
Yes | Yes |
| Health metrics | No | Agent telemetry |
| Span enrichment | No | Yes |
ExposureHook accessors getFlagKey(), getVariant(), getAllocationKey(), getTargetingKey() |
The next release after 1.68.1 | The next release after 1.68.1 |
To load only part of the flag configuration, give the provider a flag selection. It then loads the flags that have any of the tags, or whose key matches any of the key patterns:
import com.datadog.openfeature.FlagSelection;
import com.datadog.openfeature.Provider;
import dev.openfeature.sdk.OpenFeatureAPI;
import java.util.List;
OpenFeatureAPI.getInstance().setProviderAndWait(new Provider(new Provider.Options()
.flagSelection(new FlagSelection()
.tags(List.of("checkout"))
.keyPatterns(List.of("checkout.*")))));- Tags match exactly and case-sensitively. A key pattern matches the whole key, case-sensitively:
*matches any run of characters, and every other character is literal. - Evaluating a flag outside the selection returns the default value with
FLAG_NOT_FOUND. A selection that matches no flag loads an empty configuration. - Leading and trailing Unicode white space is trimmed from every value, and empty and duplicate values are dropped. A null list is treated as absent.
- Each list accepts at most 31 values, and each tag and key pattern is at most 200 UTF-8 bytes. A selection over a limit, one holding a null or non-
Stringvalue or an unpaired UTF-16 surrogate, or one that would make the request URL longer than 8192 bytes, is not sent. The provider logs an error, for exampleflagSelection was not sent (too_many_values: each list accepts at most 31 values). Loading the full flag configuration., and loads all the flags. - The server can also ignore a selection. It then returns all the flags, and the provider logs
flagSelection was ignored by the server (<reason>). Loaded the full flag configuration.once per reason. A custom configuration endpoint must forward theselected_flag_tagsandselected_flag_key_patternsquery parameters, and theDD-Flag-Selection-Ignoredresponse header. - The selection is set in code only, and the provider captures it at construction.
- The providers of a class loader share one flag configuration. The first provider initialized decides the selection, including a provider without one, which loads all the flags. A later provider with a different selection uses the first selection, until the last provider shuts down; the first such provider logs a warning, once per class loader.
- The
remote_configsource does not support a selection: the provider logs a warning and loads all the flags. - With
dd-java-agent, dropped and ignored selections are also counted in the agent health metrics.
The provider sends exposures to Datadog. To also record exposures in your own data store, register ExposureHook from dd-openfeature. It receives every completed evaluation, with the same exposure decision that the provider uses for Datadog.
import com.datadog.openfeature.ExposureHook;
BlockingQueue<ExposureRecord> queue = new LinkedBlockingQueue<>(10_000);
OpenFeatureAPI.getInstance().addHooks(new ExposureHook(evaluation -> {
if (!evaluation.shouldSend()) {
return;
}
Map<String, Object> features = evaluation.getFeatures();
queue.offer(new ExposureRecord(
evaluation.getFlagKey(),
evaluation.getVariant(),
evaluation.getAllocationKey(),
evaluation.getTargetingKey(),
(String) features.get("holdout.key"),
(String) features.get("holdout.assignment_group")));
}));
// A background thread drains the queue and writes to the data store.- Each record needs the flag key, the variant, the allocation key and the targeting key:
getFlagKey(),getVariant(),getAllocationKey()andgetTargetingKey(). The analysis of a selective holdout uses the allocation key.getVariant()andgetAllocationKey()returnnullwhen the provider selected no allocation, andgetTargetingKey()returnsnullwhen the context has no targeting key.getDetails()andgetContext()give the full evaluation details and context. - The callback runs on the evaluation thread. Do not write to the data store from the callback. Copy what you need and hand it to a background queue.
shouldSend()is true for a successful evaluation of an allocation that logs exposures, for a subject not yet exposed to the same allocation, variant and serial id. These are exactly the exposures that the provider sends to Datadog, as long as Datadog logging is on and the provider's own hooks run: evaluate through an OpenFeature client, and inside aMultiProvideruse OpenFeature SDK 1.23.0 or later. With an older SDK, a provider inside aMultiProvidersends no exposures, andshouldSend()is true for every exposure.isExposure()is true for every successful evaluation of an allocation that logs exposures, including repeats.isCacheHit()tells repeats apart.- An evaluation that fails, including one that a later
afterhook fails, is not an exposure. - An exception from the callback does not affect the evaluation. The first one is logged at warn level, later ones at debug level.
getFeatures() returns the features of the selected split whose destinations include HOOK. Values are a String, Double or Boolean. Holdout splits carry:
| Feature | Value |
|---|---|
holdout.key |
The holdout key |
holdout.assignment_group |
status_quo or all_shipped |
The map is empty when the split has no such features. Datadog can add destinations later; the provider ignores a destination it does not know and logs a warning once for each one.
Hooks that use only the OpenFeature API can read the allocation key and the features from the evaluation's flag metadata. Read them in the hook's finallyAfter stage, where the details match what the application receives, and skip details that have an error code. The exposure decision (shouldSend(), isExposure(), isCacheHit()) is available only from ExposureHook. Other keys that start with __dd_ are internal and can change without notice.
| Key | Type | Meaning |
|---|---|---|
allocationKey |
String | The selected allocation. ExposureHook also gives it as getAllocationKey() |
__dd_feature.<key> |
String, Double or Boolean | One entry for each feature of the selected split that lists the HOOK destination |
DD_FEATURE_FLAGS_EXPOSURES_DATADOG_LOGGING_ENABLED=falseThe provider then sends no exposures to Datadog. ExposureHook callbacks still receive every evaluation, and shouldSend() gives the same result as before. The default is true.
This setting stops exposures only. Flag evaluation events have their own setting, DD_FLAGGING_EVALUATION_COUNTS_ENABLED. The Java provider does not read dd-trace-py's DD_FFE_INTAKE_ENABLED.
To make evaluations stop counting as exposures, rather than only stop sending them, see Evaluation telemetry and exposures.
A provider has two independent options. Each is on by default and applies to that provider only:
| Provider option | When off |
|---|---|
evaluationTelemetryEnabled(false) |
No flag evaluation events, no feature_flag.evaluations metric, and no span enrichment. |
exposuresEnabled(false) |
Evaluations are not exposures: none is recorded, deduplicated, or sent to Datadog, and ExposureHook reports them with isExposure() and shouldSend() false. With span enrichment on, the span records the evaluation but not the subject. |
Neither option changes flag results or assignment. The provider reads both at construction.
Process-wide, DD_FLAGGING_EVALUATION_COUNTS_ENABLED=false stops flag evaluation events, and DD_FEATURE_FLAGS_EXPOSURES_DATADOG_LOGGING_ENABLED=false stops sending exposures to Datadog. Neither setting stops the feature_flag.evaluations metric, which is recorded whenever OpenTelemetry supplies a working meter. To stop evaluation metrics across the process, set evaluationTelemetryEnabled(false) on every Datadog provider. Span enrichment is off by default.
Some applications decide something ahead of time, such as which version of a notification to send, and expose the subject only when they act on it, such as when they open the notification. Register a second provider for the inspection, under its own OpenFeature domain, with both options off:
import com.datadog.openfeature.Provider;
import dev.openfeature.sdk.Client;
import dev.openfeature.sdk.MutableContext;
import dev.openfeature.sdk.OpenFeatureAPI;
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
api.setProviderAndWait("live", new Provider());
api.setProviderAndWait("peek", new Provider(new Provider.Options()
.evaluationTelemetryEnabled(false)
.exposuresEnabled(false)));
Client live = api.getClient("live");
Client peek = api.getClient("peek");
MutableContext user = new MutableContext("user-123");
// At send time: the variant the subject gets, with no exposure or evaluation telemetry.
String planned = peek.getStringValue("digest-subject-line", "control", user);
// When the subject opens the notification: the same variant, and the exposure.
String seen = live.getStringValue("digest-subject-line", "control", user);- Both providers share the process's flag configuration, so for the same flag, targeting key, attributes and configuration, and the same
experimentationOptOutMode, they return the same variant. - An inspection does not mark the subject as exposed, so the later live evaluation still sends the exposure.
- Evaluate inspections through the inspection domain's client only. Hooks that the application registers itself, at the API or client level, still run.
Set DD_FEATURE_FLAGS_EXPERIMENTATION_OPT_OUT_MODE=immediate before constructing the provider.
The default is disabled. Existing configuration delivery and credentials are still required.
import com.datadog.openfeature.Provider;
import dev.openfeature.sdk.MutableContext;
import dev.openfeature.sdk.OpenFeatureAPI;
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
api.setProviderAndWait(new Provider());
boolean enabled = api.getClient().getBooleanValue("new-checkout", false,
new MutableContext("subject-123")
.add("dd_experimentation_opt_out_at", "2026-10-19T12:00:00Z"));In immediate mode, a valid timestamp string excludes the subject from allocations with doLog=true.
This includes completed-experiment winners that still log exposures; omitted, null, and false doLog retain Java's ordinary-allocation behavior.
Evaluation continues through ordinary feature allocations. If none match, the provider returns the application's default.
A future timestamp also takes effect immediately. It does not schedule exclusion.
Omit the attribute for subjects who can participate. OpenFeature merges API, transaction, client, and invocation contexts. Omitting it from an invocation does not remove an inherited value; remove it from the layer that owns it. Setting it to null does not restore participation.
Invalid, null, empty, or non-string values return the application's default with INVALID_CONTEXT and a diagnostic.
This validation runs after configuration readiness and before flag lookup, so it also applies to ordinary and missing
flags. Before configuration is ready the result remains PROVIDER_NOT_READY. Disabled mode ignores the attribute,
including invalid values. Supply Instant.toString() as a string; passing an Instant object is invalid.
Java uses DateTimeFormatter.ISO_OFFSET_DATE_TIME, also used for allocation startAt, endAt, and activation.
It validates calendar dates, accepts up to nine fractional digits and offsets through ±18:00, and rejects leap
seconds, missing offsets, and surrounding whitespace. Its ISO syntax also accepts lowercase t/z, omitted
seconds, an empty fractional part, hour-only or second-bearing offsets, and signed extended years. This is Java's
existing grammar, not the browser SDK's timestamp grammar.
An explicit option overrides configuration:
import com.datadog.openfeature.ExperimentationOptOutMode;
Provider provider = new Provider(new Provider.Options()
.experimentationOptOutMode(ExperimentationOptOutMode.DISABLED));DEFAULT reads the normal SDK configuration sources, including
-Ddd.feature.flags.experimentation.opt.out.mode=immediate.
The provider resolves the mode at construction; later changes to options or configuration do not change it.
Unsupported values throw IllegalArgumentException when Feature Flags is enabled. A disabled product skips this
unused setting's validation and retains its existing initialization behavior. Passing null to the option throws
NullPointerException.
The deprecated datadog.trace.api.openfeature.Provider alias uses the same evaluator
and accepts the same com.datadog.openfeature.ExperimentationOptOutMode options.
This setting is independent of evaluation telemetry opt-out. Immediate withdrawal can change an enrolled subject's experience. Account for this change in experiment analysis.
Use future_experiments_only or ExperimentationOptOutMode.FUTURE_EXPERIMENTS_ONLY to exclude newer experiments.
Supply the same stored dd_experimentation_opt_out_at timestamp with each evaluation.
For exposure-logging allocations, the provider compares randomizationActivatedAt with that timestamp:
| Allocation activation | Behavior |
|---|---|
| Before the subject's opt-out time | Evaluate normally, including exposure logging |
| Equal to or after the opt-out time | Skip the allocation and continue ordinary delivery |
| Missing or null | Skip the allocation because its activation time is unknown |
Ordinary allocations remain available. Missing subject attributes preserve normal evaluation.
Both enabled modes reject invalid subject timestamps.
Malformed activation metadata on any allocation, including an ordinary, unreachable, or disabled flag's allocation,
returns PARSE_ERROR for the affected flag only in future mode with a valid subject timestamp.
Disabled mode, immediate mode, and evaluations without a subject timestamp preserve ordinary evaluation.
Invalid regex patterns and unconvertible numeric variant values are configuration errors regardless of opt-out:
the parser rejects only the affected flag, including when the malformed allocation would be skipped.
Java's existing regex syntax and numeric coercions remain supported.
Comparisons retain nanosecond precision and account for timezone offsets.
The cutoff does not depend on the SDK clock. It is not a scheduled change or proof of prior enrollment.
An older allocation can still assign a subject for the first time.
Enable future mode after the configuration service supplies stable activation timestamps and preserves ordinary fallback allocations. Keep the subject's stored opt-out time stable across sessions and SDK instances. The provider stores no consent history and emits no new event type. The opt-out attribute remains in the evaluation context: existing exposure reports can include it, and evaluation events can include it when full evaluation data reporting is enabled. Existing reporting controls and consent settings still apply.
Applications can keep flag evaluation enabled while excluding selected subjects from evaluation telemetry. Configure the provider once, then pass the decision with each evaluation:
import com.datadog.openfeature.Provider;
import dev.openfeature.sdk.Client;
import dev.openfeature.sdk.ImmutableContext;
import dev.openfeature.sdk.OpenFeatureAPI;
import dev.openfeature.sdk.Value;
import java.util.Collections;
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
api.setProviderAndWait(new Provider(
new Provider.Options().enableEvaluationTelemetryOptOutParameter(true)));
Client client = api.getClient();
// In a request handler, the application owns its consent and eligibility rules.
boolean optedOut = user.hasDeclinedEvaluationTelemetry();
boolean enabled = client.getBooleanValue("my-feature", false,
new ImmutableContext(user.getId(), Collections.singletonMap(
"dd_evaluation_telemetry_opt_out", new Value(optedOut))));Use the per-evaluation context for concurrent requests. Do not replace the global context for each
subject. The key is exactly dd_evaluation_telemetry_opt_out, as in other Datadog SDKs.
Alternatively, enable support through deployment configuration and use new Provider():
DD_FEATURE_FLAGS_EVALUATION_TELEMETRY_PER_SUBJECT_OPT_OUT_ENABLED=trueThe equivalent JVM property is -Ddd.feature.flags.evaluation.telemetry.per.subject.opt.out.enabled=true.
The provider reads the normal Datadog configuration sources at construction. The default is false.
An explicit provider option overrides these sources, including an explicit false.
This setting only enables support for the subject attribute. It does not suppress telemetry for all subjects.
Only boolean true suppresses telemetry. Missing, false, null, and other types preserve telemetry.
The provider suppresses telemetry only when the option is enabled before provider construction.
The attribute remains available for targeting and exposure reporting with either activation setting. Existing privacy and reporting settings apply. Targeting rules can use the attribute to select assignments. Normal exposure deduplication applies when its value changes.
Opt-out suppresses new evaluation EVP events and counts, OpenTelemetry evaluation metrics, and automatic flag-related span enrichment. It does not change flag values, evaluation details, application defaults, experiment assignment, or exposure logging. Application hooks and unrelated tracing remain active. Previously recorded or queued data is not removed.
- The provider moved to
com.datadog.openfeature.Provider, and the exposure hook tocom.datadog.openfeature.ExposureHook.datadog.trace.api.openfeature.Provideranddatadog.trace.api.openfeature.ExposureHookare kept as deprecated aliases. - The SDK no longer requires
dd-java-agentand no longer links against agent classes. dd-openfeaturereleases before 1.69.0 link to agent classes thatdd-java-agent1.69.0 removes: withdd-java-agent1.69.0 or later, they return the caller default values. Upgradedd-openfeatureto 1.69.0 or later together withdd-java-agent.
The SDK does not use any dd-trace-java internal module. Its parts that the agent can provide are behind the com.datadog.openfeature.internal.bridge.v1 SPI:
AgentBridges.detect()returnsAgentBridge.NONEwithout the agent.- The
:dd-java-agent:instrumentation:datadog:openfeature:dd-openfeature-1.69instrumentation replaces its result with a bridge delegating to the agent backend (products/feature-flagging/feature-flagging-lib) through the bootstrapFeatureFlaggingGateway. - The
:dd-java-agent:instrumentation:datadog:openfeature:dd-openfeature-1.56instrumentation keeps the providers released before the bridge (1.56 to 1.68) from linking to the agent bootstrap API they used: they return the caller defaults. - The SPI is the only contract crossing SDK and agent versions, and the instrumentation references to it are checked by muzzle. Once released, an SPI version is frozen: only
defaultmethods can be added. A breaking change goes to a new package (bridge.v2), with its own agent instrumentation, and the SDK keeps the previous version for the agents that only implement it. ThejapicmpBridgetasks check each released SPI version against the first SDK release that shipped it. - UFC parsing, evaluation, event payloads and batching stay in the SDK. The agent forwards raw Remote Configuration documents and event payloads.
- The public API is everything outside the
internalpackages. ThejapicmpPublicApitask checks it stays binary and source compatible with the previous release, the latest one before the version being built, so each release keeps the API of all the previous ones. Exclude an intentional break explicitly.