Closed crinklywrappr closed 1 year ago
Hi Daniel! Sorry I'm not quite sure what you're asking, could you please expand a little on what you're trying to do?
traceid & spanid allows datadog to correlate logs with higher-level things eg HTTP requests and database queries.
They provide instructions (in the link provided) how to add traceid and spanid to log4j/slf4j logs.
I would like to do the same with timbre but don't know how.
I can try offer some ideas, though the best solution will depend on the details of your setup and the specific tradeoffs you'd prefer to make.
It sounds like the goal is to have some sort of useful logical id available at the relevant logging callsites. That's something you'd need to design yourself - it's outside the scope of a logging library.
Common options would include setting up the relevant logical id context using binding
and your own dynamic var, or using Timbre's with-context (which is itself just a dynamic var).
If you're talking about a Ring server, this pattern is often quite easy to do with a middleware that setups up the dynamic context before calling subsequent request handlers.
Though the semantics of what constitutes a logical span/id, how these ids are generated, etc. are all quite app dependent.
Hope that helps!
Thanks!
https://docs.datadoghq.com/tracing/connect_logs_and_traces/java/?tab=log4j2
is
with-context
the right way to do this?