Stack Exchange
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?

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:

It seems Datadog supports both of the above through the OTel collector: see the docs how to set it up
There is a zipkin to datadog proxy
There is a zipkin-datadog reporter
You can write your own for Sleuth, see: https://github.com/spring-cloud/spring-cloud-sleuth/issues/707
You can ask Datadog to add "native" support for the Zipkin format: https://github.com/DataDog/dd-trace-java/issues/351


Thank you, @Jonatan Ivanov!
I was able to send traces over setting Sleuth+Zipkin to OTel collector(DataDog exporter).
But when I try to use Sleuth-OTel, it does not send traces to OTel collector. I see some error in the log:
[nio-8080-exec-3] t.p.B3PropagatorExtractorMultipleHeaders : Invalid TraceId in B3 header: null'. Returning INVALID span context.
Also is it possible to send with Sleuth-OTel java Metrics?

@sergio Based on this, I don't really know what is the issue, you can check the Sleuth-OTel samples, they should work. Please also notice that we don't recommend using Sleuth-OTel in production (see above: it's not stable yet because of OTel is not stable yet).
Sleuth is a distributed tracing library, it does not support metrics. Micrometer is the library that you can use to record and ship metrics.
OTel Metrics does not even have a released specification so you will not be able to use it at the moment.
