Tracing in native image - Datadog
After successfully launching the spring context, in Road to Native Image (Spring Boot 3+), I've sense checked API, and added more reflection data from the agent, mainly POJOs that the native image couldn't deserialize.
This article aims at restoring observability via Datadog, particularly for traces.
Datadog relies on java agent that gets passed to the JVM in runtime to instrument the app for traces, however, we are no longer running on the JVM, let's see how we can can build a native image that supports datadog's agent instrumentation:
Setup
What you'll need are 3 elements;
1. The Datadog agent:
Terminology is a bit loose here, this is not the java agent, it's an agent provided by Datadog as well that forwards your traces to the datadog endpoints:
Install :
Configure via the datadog.yaml
file:
site: value from https://docs.datadoghq.com/getting_started/site/
api_key: your DD api key.
Check the agent status in the Datadog Agent Manager on http://localhost:5002
You should be able to see this :
2. The Java Jar agent:
Download the jar provided by DD:
3. The Datadog libraries for custom instrumentation (optional):
Spring Boot is fully supported through spring-web / spring-webflux
Build Native Image with Datadog Agent:
At properties level:
Pass it to native image plugin arguments:
Rebuild your native image :
Run with a custom service identifier for instance:
Traces
Check if your traces are being sent to DD Agent on the Agent Manager:
On the DD APM UI, check that you are receiving traces, here is a metric push example that was captured: