Extract opentracing TraceId for use in logging?

85 views
Skip to first unread message

André Fachat

unread,
Mar 28, 2019, 5:49:00 AM3/28/19
to Eclipse MicroProfile
Hi there,

just a quick question, as I could not find the solution after some search.

I want to extract the opentracing TraceId, and use it (print it) in my logs so I can use it as correlation ID, to correlate logs from the same request (trace) in ELK.
I would like to do it in a WebFilter, that would extract the TraceID and puts it e.g. into log4j diagnostic context.
What is the easiest/preferred/allowed way of doing this?

[Note: as far as I understand, the TraceId is a "global" correlator created at the "entry" of a request into the system and the same across all spans in that request]

Many thanks in advance
André


#opentracing #microprofile

Gary Brown

unread,
Mar 28, 2019, 6:05:18 AM3/28/19
to MicroProfile
Hi André

The ability to obtain the trace id from an active span (context) has only just been added to the Java OpenTracing API, as of version 0.32.0 released 3 days ago.

Therefore you would need to wait for tracers to become available that support that version of the API.

Regards
Gary


--
You received this message because you are subscribed to the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile...@googlegroups.com.
To post to this group, send email to microp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/d9b9ca4d-9b41-457c-92f0-d3dc996f4c45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

André Fachat

unread,
Mar 28, 2019, 8:21:56 AM3/28/19
to Eclipse MicroProfile
Ok, thanks, good to know!

André Fachat

unread,
Mar 28, 2019, 8:23:42 AM3/28/19
to Eclipse MicroProfile
As a followup, for now, if that is not yet available, I could create an own ID, and put it into the "baggage", would that be transferred to child-spans?


On Thursday, 28 March 2019 10:49:00 UTC+1, André Fachat wrote:

Gary Brown

unread,
Mar 28, 2019, 10:18:52 AM3/28/19
to MicroProfile
Correct - that should work if the tracer implementation supports the baggage propagation.


--
You received this message because you are subscribed to the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile...@googlegroups.com.
To post to this group, send email to microp...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages