OK, I spent quiet some time figuring out how to configure stuff to have DataDog trace ID in logs but couldn't get it working. To be clear what I'm looking for is to see trace IDs in logs message, the same way that adding spring-cloud-starter-sleuth to the classpath, automatically configure Slf4j/Logback to show trace IDs in log messages.
Where I've started:
dd-trace-ot or any opertracing libs)What I did so far:
opentracing-spring-cloud-starter will add log integration automatically. But I couldn't get it working.dd-trace-ot didn't help.Notes:
Can someone tell me how exactly I need to configure the application to see trace IDs in log messages? Is there any documentation or samples I can look at?
Do you have the ability to add some parameters in the logs sent. From the documentation you should be able to inject the trace id into your logs in a way that Datadog will interpret them.
You can also look at a parser to extract the trace id and span id from the raw log. This documentation should help you out on that.
From the documentation, if you don't have JSON logs, you need to include dd.trace_id and dd.span_id in your formatter:
If your logs are raw formatted, update your formatter to include
dd.trace_idanddd.span_idin your logger configuration:<Pattern>"%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %X{dd.trace_id:-0} %X{ dd.span_id:-0} - %m%n"</Pattern> ```
So if you add %X{dd.trace_id:-0} %X{ dd.span_id:-0}, it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With