-
Notifications
You must be signed in to change notification settings - Fork 343
Conversation
Puts active Spans's debug_id when scope is activated and cleans it afterwards.
private static class MockSpanDebugId implements SimpleMdcScopeManager.DebugIdProvider { | ||
@Override | ||
public String get(Span span) { | ||
MockSpan.MockContext ctx = ((MockSpan) span).context(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Real implementation will also require casting so other libs that wrap Span will make it fail :|
@Override | ||
public Scope activate(Span span, boolean finishSpanOnClose) { | ||
Scope scope = wrapped.activate(span, finishSpanOnClose); | ||
String debugId = MDC.get(mdcKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call it something other than debugId
so you don't have to use this.debugId
for the instance field? (same name but different types, etc)
Out of curiosity: is this something you would foresee being implemented as a wrapper class? I ask because if the user does
|
Oh, you're right. I should pass my If this wouldn't be a wrapper then it wouldn't be possible to use it with another scope manager (e.g. |
Wondering when this feature will become available. |
@mabn Isn't this what https://github.com/opentracing-contrib/java-api-extensions is for? |
I haven't tried api-extensions, but subclassed the scope manager to add trace IDs to logs. |
As long as 0.32.0 is not released there is no way to get this done without being implementation-specific, right? |
@whiskeysierra yeah. Even with 0.32, the |
@whiskeysierra yes, java-api-extensions would be suitable, but IIRC at the time they didn't have some of the callbacks I needed I'm closing this PR as I haven't worked on this for quite a while. |
An example of keeping Span's debug_id inside MDC - for version 0.31.0+
Puts active Spans's debug_id when scope is activated and cleans it
afterwards.
see also: #206