You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Marcin Grzejszczak (Jira)" <ji...@apache.org> on 2023/03/07 15:51:00 UTC
[jira] [Created] (CAMEL-19124) Tracer doesn't continue spans for AbstractInternalSpanDecorator
Marcin Grzejszczak created CAMEL-19124:
------------------------------------------
Summary: Tracer doesn't continue spans for AbstractInternalSpanDecorator
Key: CAMEL-19124
URL: https://issues.apache.org/jira/browse/CAMEL-19124
Project: Camel
Issue Type: Bug
Components: camel-tracing
Affects Versions: 3.20.2, 3.x, 4.0
Reporter: Marcin Grzejszczak
Attachments: trace_view_with_fix.png, trace_view_without_fix.png
As discussed in the [PR|https://github.com/apache/camel/pull/9389] it seems that the `Tracer`component from `camel-tracing` is not continuing spans if a `AbstractInternalSpanDecorator` is being created. So for the following route
{code:java}
from("direct://foo")
.log("hello")
.to("direct://bar")
.to("http://example.org");
from("direct://bar")
.log("hello")
.to("direct://micrometer")
.to("http://example.org");
from("direct://micrometer")
.setHeader(MicrometerConstants.HEADER_METRIC_NAME, constant("new.name"))
.setHeader(MicrometerConstants.HEADER_METRIC_TAGS, constant(Tags.of("dynamic-key", "dynamic-value")))
.to("micrometer:counter:name.not.used?tags=key=value")
.to("direct://baz");
from("direct://baz")
.log("hello")
.to("bean:com.example.cameldemo.MyBean")
.to("exec:wc?args=--words /usr/share/dict/words")
.process(exchange -> {
// Use the Camel Exec String type converter to convert the ExecResult to String
// In this case, the stdout is considered as output
String wordCountOutput = exchange.getIn().getBody(String.class);
// do something with the word count
System.out.println(wordCountOutput);
})
.to("file:///tmp/camel-outputdir?flatten=true")
.to("http://example.org");
{code}
you will get multiple traces since the `direct` components are not linked together (they are treated as a start of a new trace).
!trace_view_without_fix.png!
I think we agreed that for this route example, multiple routes are linked together but all in all they form a single trace. So if `org.apache.camel.tracing.Tracer.TracingEventNotifier#shouldExclude` would be changed from
{code:java}
private boolean shouldExclude(SpanDecorator sd, Exchange exchange, Endpoint endpoint) {
return sd instanceof AbstractInternalSpanDecorator || !sd.newSpan()
|| isExcluded(exchange, endpoint);
}
{code}
to
{code:java}
private boolean shouldExclude(SpanDecorator sd, Exchange exchange, Endpoint endpoint) {
return !sd.newSpan()
|| isExcluded(exchange, endpoint);
}
{code}
then the span parent-child relationship gets maintained the way it should
!trace_view_with_fix.png!
--
This message was sent by Atlassian Jira
(v8.20.10#820010)