[
https://issues.apache.org/jira/browse/CAMEL-11646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16118490#comment-16118490
]
Anton Koscejev commented on CAMEL-11646:
----------------------------------------
According to the [OpenTracing API
documentation|https://github.com/opentracing/opentracing-java] it seems that
the spans should be activated and deactivated.
E.g., a span can be created via {{Tracer.SpanBuilder.startActive()}} or it can
be created via {{Tracer.SpanBuilder.startManual()}}
(which is done right now, except using the deprecated {{start()}} method) and
later activated via {{ActiveSpanSource.makeActive()}}.
Consequently, an ActiveSpan should be deactivated via
{{ActiveSpan.deactivate()}}.
The activation/deactivation is currently not done - this is probably a
bug/oversight. This results in any CurrentTraceContext not working correctly,
which is why MDCCurrentTraceContext cannot be applied.
A workaround that seems to work, but is probably not performing (de)activation
at the correct time:
{code}
@Bean
InterceptStrategy activateSpanInterceptStrategy(Tracer tracer) {
// CAMEL-11646 spans are not activated currently
return (context, definition, target, nextTarget) -> exchange -> {
Optional<ActiveSpan> activeSpan =
Optional.ofNullable(ActiveSpanManager.getSpan(exchange))
.map(tracer::makeActive);
try {
target.process(exchange);
} finally {
activeSpan.ifPresent(ActiveSpan::deactivate);
}
};
}
{code}
Perhaps this logic can just be built into ActiveSpanManager, so it "holds" an
ActiveSpan instance, not Span?
> Upgrade brave to allow simple MDC logging
> -----------------------------------------
>
> Key: CAMEL-11646
> URL: https://issues.apache.org/jira/browse/CAMEL-11646
> Project: Camel
> Issue Type: New Feature
> Components: camel-opentracing
> Affects Versions: 2.19.1
> Reporter: Radek Mensik
>
> It would be nice if spans are logged as we know it from spring-sleuth.
> Simplest could be usage of brave-context-slf4j
> https://github.com/openzipkin/brave/tree/master/context/slf4j.
> Unfortunately this requires higher version of brave. I tried to make it work
> with 2.20.0-SNAPSHOT but no luck..
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)