Search code examples
spring-bootdatadogspring-cloud-sleuth

Send traces with spring-boot-sleuth to Datadog


I have spring-boot application and it has the next dependencies:

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation "com.datadoghq:dd-java-agent:0.75.0"
annotationProcessor "com.datadoghq:dd-java-agent:0.75.0"
testImplementation 'org.springframework.boot:spring-boot-starter-test'}

bootRun {
   jvmArgs = ["-javaagent:" + configurations.runtimeClasspath.files.find { f -> f.path.contains('dd-java-agent') }.path]
}

I execute Datadog agent in the container and configure it there(KEY, ENV).

When I use API from dd-trace (like datadog.trace.api.Trace), I can see traces in Datadog. But when I use sleuth API to create spans/tags/events I cant see traces.

Is it possible to use sleuth API to send traces to Datadog via Datadog agent? If yes, what do I need to do for it?


Solution

  • Spring Cloud Sleuth supports two tracing libraries:

    • Brave: the tracing lib of OpenZipkin (Sleuth uses this by default)
    • OpenTelemetry: you need to add Sleuth-OTel but it is in incubator so not recommended in production, also OpenTelemetry Java is still in alpha

    There are a few things you can do: