Adding traceId/spanId to accesslogs and applogs
withnale opened this issue · 1 comments
I've been following the various opentracing/jaeger/zipkin java client repos looking for some guidance on the cleanest way to get traceId/spanId into the logs. There has been some discussion in various places on this topic but nothing definitive and no code anywhere (unless I look in the brave implementation)
At present we are running our application inside a tomcat container, deployed as a war.
I've got basic span/trace forwarding working however I'd also like to enrich both our access logs and application logs so that these can also be used for diagnosis.
For application logs we are using logback and so my assumption is the cleanest way to manage this would be to write the relevant information into MDC and use logback native patterns to include the relevant fields.
For tomcat access logs, I would assume I would need to update the values into either the request or response context and use AccessLogValve patterns to pick this up.
However, I'm unsure of the best place to populate these. Should I write this functionality as an additional filter, or extend one of the existing classes? Is there any prior art I have missed that would make this easier?
Hi, as the IDs are not exposed by the OT API you have to cast the context to the current impl to get them.
This will change in opentracing/opentracing-java#314.
I am closing this as it is not related to jax-rs. Feel free to continue the discussion.