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:
- We've got a simple web spring boot application running as a Docker container deployed as an AWS Elastic BeansTalk, whose logs go to CloudWatch and we read them there.
- We have DataDog as a Java agent (thus no dependencies in pom.xml)
- We have SLF4J/Logback in our dependencies list.
- There's no other related depndencies (like
dd-trace-ot
or anyopertracing
libs)
What I did so far:
- I found on SO that adding
opentracing-spring-cloud-starter
will add log integration automatically. But I couldn't get it working. - On DD website, it says configuring the pattern is enough to see the IDs, but in our case it didn't work. (is it because we don't have our logs a JSON?). Also, adding
dd-trace-ot
didn't help.
Notes:
- We can't switch to JSON logs.
- We can't switch to any other library (e.g. Slueth).
- We can't go away from CloudWatch.
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?