Skip to content

Commit 18c0441

Browse files
committed
Add README for dd-openfeature with eval metrics setup
Documents the published artifact setup, evaluation metrics dependencies (opentelemetry-sdk-metrics, opentelemetry-exporter-otlp), OTLP endpoint configuration, metric attributes, and requirements.
1 parent 69c5529 commit 18c0441

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

  • products/feature-flagging/feature-flagging-api
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# dd-openfeature
2+
3+
Datadog OpenFeature Provider for Java. Implements the [OpenFeature](https://openfeature.dev/) `FeatureProvider` interface for Datadog's Feature Flags and Experimentation (FFE) product.
4+
5+
Published as `com.datadoghq:dd-openfeature` on Maven Central.
6+
7+
## Setup
8+
9+
```xml
10+
<dependency>
11+
<groupId>com.datadoghq</groupId>
12+
<artifactId>dd-openfeature</artifactId>
13+
<version>${dd-openfeature.version}</version>
14+
</dependency>
15+
<dependency>
16+
<groupId>dev.openfeature</groupId>
17+
<artifactId>sdk</artifactId>
18+
<version>1.20.1</version>
19+
</dependency>
20+
```
21+
22+
### Evaluation metrics (optional)
23+
24+
To enable evaluation metrics (`feature_flag.evaluations` counter), add the OpenTelemetry SDK dependencies:
25+
26+
```xml
27+
<dependency>
28+
<groupId>io.opentelemetry</groupId>
29+
<artifactId>opentelemetry-sdk-metrics</artifactId>
30+
<version>1.47.0</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>io.opentelemetry</groupId>
34+
<artifactId>opentelemetry-exporter-otlp</artifactId>
35+
<version>1.47.0</version>
36+
</dependency>
37+
```
38+
39+
Any OpenTelemetry API 1.x version is compatible. If these dependencies are absent, the provider operates normally without metrics.
40+
41+
## Usage
42+
43+
```java
44+
import datadog.trace.api.openfeature.Provider;
45+
import dev.openfeature.sdk.OpenFeatureAPI;
46+
import dev.openfeature.sdk.Client;
47+
48+
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
49+
api.setProviderAndWait(new Provider());
50+
Client client = api.getClient();
51+
52+
boolean enabled = client.getBooleanValue("my-feature", false,
53+
new MutableContext("user-123"));
54+
```
55+
56+
## Evaluation metrics
57+
58+
When the OTel SDK dependencies are on the classpath, the provider records a `feature_flag.evaluations` counter via OTLP HTTP/protobuf. Metrics are exported every 10 seconds to the Datadog Agent's OTLP receiver.
59+
60+
### Configuration
61+
62+
| Environment variable | Description | Default |
63+
|---|---|---|
64+
| `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` | Signal-specific OTLP endpoint (used as-is) ||
65+
| `OTEL_EXPORTER_OTLP_ENDPOINT` | Generic OTLP endpoint (`/v1/metrics` appended) ||
66+
| (none set) | Default endpoint | `http://localhost:4318/v1/metrics` |
67+
68+
### Metric attributes
69+
70+
| Attribute | Description |
71+
|---|---|
72+
| `feature_flag.key` | Flag key |
73+
| `feature_flag.result.variant` | Resolved variant key |
74+
| `feature_flag.result.reason` | Evaluation reason (lowercased) |
75+
| `error.type` | Error code (lowercased, only on error) |
76+
| `feature_flag.result.allocation_key` | Allocation key (when present) |
77+
78+
## Requirements
79+
80+
- Java 11+
81+
- Datadog Agent with Remote Configuration enabled
82+
- `DD_EXPERIMENTAL_FLAGGING_PROVIDER_ENABLED=true`

0 commit comments

Comments
 (0)