-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[FFL-2653] Document Java flag evaluation metrics setup #37927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
eb91e70
dd2600d
bdc4107
ddc23e6
61e32ba
267dab3
7892c88
a503090
64b64fc
0823ed9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,19 +51,79 @@ You only need to enable the protocol your application uses (gRPC on port 4317, o | |
|
|
||
| ## Step 2: Configure your application | ||
|
|
||
| Set the following environment variable on your application, in addition to the standard [server-side feature flag configuration][1]: | ||
| Set the following environment variable in addition to the standard [server-side feature flag configuration][1]: | ||
|
|
||
| {{< code-block lang="bash" >}} | ||
| # Enable flag evaluation metrics | ||
| DD_METRICS_OTEL_ENABLED=true | ||
| {{< /code-block >}} | ||
|
|
||
| **Note**: The Java tracer does not use `DD_METRICS_OTEL_ENABLED`. Skip this variable and see [Java: Add the OpenTelemetry SDK dependencies](#java-add-the-opentelemetry-sdk-dependencies) instead. | ||
|
|
||
| ### Java: Add the OpenTelemetry SDK dependencies | ||
|
|
||
| The Java provider records `feature_flag.evaluations` through the OpenTelemetry SDK and exports it over OTLP, so the `opentelemetry-sdk-metrics` and `opentelemetry-exporter-otlp` dependencies must be on your application's classpath. Add them alongside your [Java feature flag dependencies][6]. Import the OpenTelemetry BOM so the OpenTelemetry API and SDK stay on the same version: | ||
|
|
||
| {{< tabs >}} | ||
| {{% tab "Gradle (Groovy)" %}} | ||
| {{< code-block lang="groovy" filename="build.gradle" >}} | ||
| dependencies { | ||
| implementation platform('io.opentelemetry:opentelemetry-bom:1.47.0') | ||
| implementation 'io.opentelemetry:opentelemetry-sdk-metrics' | ||
| implementation 'io.opentelemetry:opentelemetry-exporter-otlp' | ||
| } | ||
| {{< /code-block >}} | ||
| {{% /tab %}} | ||
|
|
||
| {{% tab "Gradle (Kotlin)" %}} | ||
| {{< code-block lang="kotlin" filename="build.gradle.kts" >}} | ||
| dependencies { | ||
| implementation(platform("io.opentelemetry:opentelemetry-bom:1.47.0")) | ||
| implementation("io.opentelemetry:opentelemetry-sdk-metrics") | ||
| implementation("io.opentelemetry:opentelemetry-exporter-otlp") | ||
| } | ||
| {{< /code-block >}} | ||
| {{% /tab %}} | ||
|
|
||
| {{% tab "Maven" %}} | ||
| {{< code-block lang="xml" filename="pom.xml" >}} | ||
| <dependencyManagement> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>io.opentelemetry</groupId> | ||
| <artifactId>opentelemetry-bom</artifactId> | ||
| <version>1.47.0</version> | ||
| <type>pom</type> | ||
| <scope>import</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </dependencyManagement> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>io.opentelemetry</groupId> | ||
| <artifactId>opentelemetry-sdk-metrics</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.opentelemetry</groupId> | ||
| <artifactId>opentelemetry-exporter-otlp</artifactId> | ||
| </dependency> | ||
| </dependencies> | ||
| {{< /code-block >}} | ||
| {{% /tab %}} | ||
| {{< /tabs >}} | ||
|
|
||
| On the Java tracer, the provider starts its OTLP metrics exporter automatically when the OpenTelemetry SDK is on the classpath. Adding these dependencies enables the metric; `DD_METRICS_OTEL_ENABLED` is not required for Java and setting it alone has no effect. If the dependencies are missing, no metrics are emitted and the tracer logs `OpenTelemetry SDK is not on the classpath`. | ||
|
|
||
| <div class="alert alert-info">In Spring Boot applications, Spring Boot's OpenTelemetry autoconfiguration also creates an <code>OpenTelemetrySdk</code> bean. If the OpenTelemetry SDK version it resolves does not match the OpenTelemetry API version on the classpath, startup fails with a <code>BeanCreationException</code> for the <code>openTelemetry</code> bean and <code>NoClassDefFoundError: io/opentelemetry/sdk/internal/ScopeConfigurator</code>. Importing the <code>opentelemetry-bom</code> as shown above keeps the API and SDK on the same version and resolves the error.</div> | ||
|
|
||
| ### Set the OTLP endpoint | ||
|
|
||
| By default, most tracers send OTLP metrics to the Agent at `DD_AGENT_HOST` on port `4318` (HTTP). If your application already sets `DD_AGENT_HOST` to reach the Agent, no endpoint configuration is required. | ||
|
|
||
| Set an OTLP endpoint explicitly in any of these cases: | ||
|
|
||
| - The Agent is not reachable at `DD_AGENT_HOST` on the default OTLP port (for example, a remote Agent or a non-default port). | ||
| - You use the **Java** tracer. The Java tracer does not derive the endpoint from `DD_AGENT_HOST`; it defaults to `localhost:4318`. Set the endpoint whenever the Agent is not on `localhost`. | ||
| - You use the **Java** tracer. Its flag evaluation metrics exporter supports OTLP/HTTP only (gRPC is not supported) and uses port `4318`. It does not derive the endpoint from `DD_AGENT_HOST` and defaults to `http://localhost:4318`. Set `OTEL_EXPORTER_OTLP_ENDPOINT` to the Agent's HTTP endpoint when the Agent is not on `localhost`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: This bullet has grown to four sentences and mixes protocol support, port, default endpoint, and configuration guidance. Since the Java tracer already has its own subsection above, consider trimming this bullet to just the endpoint/
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Response from Claude: Keeping the protocol/port detail in this bullet. The sibling Python bullet documents its transport the same way (gRPC on 4317), so keeping Java's HTTP/4318 detail here is parallel and keeps the endpoint-transport facts together in this section. I already trimmed it in a503090 (four sentences to three). Happy to split it into a dedicated Java endpoint callout in a follow-up if you'd prefer. |
||
| - You use the **Python** tracer. The Python tracer defaults to gRPC on port `4317`, not HTTP. Enable the gRPC OTLP receiver on the Agent, or override the protocol to use HTTP instead: | ||
|
|
||
| {{< code-block lang="bash" >}} | ||
|
|
@@ -151,3 +211,4 @@ The `feature_flag.evaluations` metric is a counter with the following tags: | |
| [3]: https://app.datadoghq.com/metric/explorer | ||
| [4]: https://app.datadoghq.com/metric/summary | ||
| [5]: /dashboards/ | ||
| [6]: /feature_flags/server/java/#installation | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: This alert reads more like a troubleshooting entry than setup guidance and interrupts the setup flow. Since the preceding paragraph already tells users to import the BOM, consider moving this Spring Boot detail to a troubleshooting section (or a
<details>block) so the happy-path setup stays terse.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 Response from Claude: Keeping this inline for now. It's an
alert-infocallout (already set apart from the setup prose) and it documents the exact startup failure users hit right after adding these dependencies — the specific issue this change was written to address — so co-locating it with the dependency step maximizes discoverability. Happy to move it to a dedicated troubleshooting section in a follow-up if you'd prefer.