[ 
https://issues.apache.org/jira/browse/CAMEL-23283?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18071997#comment-18071997
 ] 

Bjorn Beskow edited comment on CAMEL-23283 at 4/8/26 7:04 PM:
--------------------------------------------------------------

Interesting: Setting {{camel.micrometer.observability.trace-processors: true}} 
indeed solves both problems and makes the tests pass (traceId and spanId are 
present for all logs, and the spans are properly nested).

It is not a solution in our case (it would create lots of technical spans that 
would need to be filtered out by a complex {{{}exclude-patterns){}}}.

It may however shed some light on the root cause. I'll have a further look at 
it too. Thanks for the hint!


was (Author: beskow):
Interesting: Setting {{camel.micrometer.observability.trace-processors: true}} 
indeed solves both problems and makes the tests pass (traceId and spanId are 
present for all logs, and the spans are properly nested).

It is not a solution in our case (it would create lots of technical spans that 
would need to be filtered out by a complex {{{}exclude-patterns){}}}.

It may however shed som light in the root cause. I'll have a further look at it 
too. Thanks for the hint!

> OpenTelemetry/Micrometer traces are not exported for JMS-initiated routes
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-23283
>                 URL: https://issues.apache.org/jira/browse/CAMEL-23283
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-tracing
>    Affects Versions: 4.15.0, 4.16.0, 4.17.0, 4.18.0, 4.18.1
>            Reporter: Bjorn Beskow
>            Priority: Major
>         Attachments: jms-micrometer-observability.zip
>
>
> When using camel-micrometer-observability, traces and spans are not correctly 
> structured if a traceId and root span is not already present (as a result of 
> OTEL context propagation from the caller, or by a Spring Boot framework 
> component in front of the camel component).
> The effect is twofold:
>  * traceId and spanId is not put in the MDC context, and hence not present in 
> any logs created.
>  * Nested spans created programmatically using the Tracer are not properly 
> nested (they get their own, unique traceId's).
> This seems to be caused by missing scope management: 
> MicrometerObservabilitySpanAdapter::activate() only calls span.start() but 
> doesn't put the
> span into the tracer's thread-local scope. This means tracer.currentSpan() 
> returns null during route execution, hence the span is invisible to e.g. 
> programmatic child span creation that relies on tracer.currentSpan() to find 
> a parent span. It also becomes invisible for the MDC context.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to