Skip to content

About

The official Dynatrace OpenFeature provider for Java.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Dynatrace OpenFeature Provider for Java

The official Dynatrace OpenFeature provider for Java server-side applications.

The provider evaluates flags in-process: on initialization it fetches your flag configuration from the Dynatrace CDN and keeps it up to date in the background, so evaluations are local and do not make a network call.

Status: Early alpha — not yet ready for production use.

Installation

<dependency>
  <groupId>com.dynatrace.openfeature</groupId>
  <artifactId>dynatrace-openfeature-provider-java</artifactId>
  <version>0.6.0-alpha</version> <!-- x-release-please-version -->
</dependency>
implementation 'com.dynatrace.openfeature:dynatrace-openfeature-provider-java:0.6.0-alpha' // x-release-please-version

Usage

import com.dynatrace.openfeature.DynatraceProvider;
import dev.openfeature.sdk.*;

OpenFeatureAPI api = OpenFeatureAPI.getInstance();
api.setProviderAndWait(new DynatraceProvider(System.getenv("DT_SDK_KEY")));

Client client = api.getClient();
EvaluationContext ctx = new ImmutableContext("user-123");
boolean enabled = client.getBooleanValue("my-flag", false, ctx);

// On shutdown:
api.shutdown();

Once the provider is registered, all flag evaluation goes through the OpenFeature API. See the OpenFeature Java SDK documentation for evaluation contexts, hooks, events, and the rest of the SDK surface.

Configuration

Build a DynatraceProviderOptions and pass it as the second constructor argument:

DynatraceProviderOptions options = DynatraceProviderOptions.builder()
    .configOrigin("https://cdn.eu.fm.dynatracelabs.com")
    .metricsOrigin("https://metrics.eu.fm.dynatracelabs.com")
    .build();

api.setProviderAndWait(new DynatraceProvider(sdkKey, options));
Option Type Default Description
configOrigin(String) String derived from SDK key Override the flag configuration origin.
metricsOrigin(String) String derived from SDK key Override the evaluation metrics ingest origin.

Environment variables

Each option can also be set from an environment variable. A value set in code wins over the environment variable, which wins over the default. Empty values count as unset.

Environment variable Equivalent Format
DT_FM_SDK_KEY sdkKey constructor argument SDK key
DT_FM_CONFIG_ORIGIN configOrigin(String) URL origin
DT_FM_METRICS_ORIGIN metricsOrigin(String) URL origin
DT_FM_SSE_DISABLED disableSse() true / false

Note: if configOrigin is set, carefully consider whether metricsOrigin should be set too; an SDK proxy or custom host typically serves both.

With DT_FM_SDK_KEY set, the key can be omitted:

api.setProviderAndWait(new DynatraceProvider());

A runnable example lives in examples/local-demo.

Contributing

See CONTRIBUTING.md.

License

Apache 2.0 — see LICENSE.

About

The official Dynatrace OpenFeature provider for Java.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages