[
https://issues.apache.org/jira/browse/CAMEL-21302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17891834#comment-17891834
]
Freeman Yue Fang edited comment on CAMEL-21302 at 10/22/24 12:36 PM:
---------------------------------------------------------------------
Hi [~davsclaus],
The exception
{code}
Failed to close span scope. This exception is ignored.
{code}
exists even without my changes when async mode is used here.
And it comes from the code
{code}
} else if (event instanceof
CamelEvent.ExchangeAsyncProcessingStartedEvent eap) {
// no need to filter scopes here. It's ok to close a scope
multiple times and
// implementations check if the scope being disposed is
current
// and should not do anything if scopes don't match.
ActiveSpanManager.endScope(eap.getExchange());
}
{code}
If I read comments here correctly, this is by design.
{code}
// no need to filter scopes here. It's ok to close a scope
multiple times and
// implementations check if the scope being disposed is
current
// and should not do anything if scopes don't match.
{code}
If we close the scope already in the expected thread, it should be OK to close
it again in another thread, and that's why we see this exception and can ignore
it. And as long as we close the scope already in the expected thread, there
would be no context leak.
And for your comment
{code}
We should look at only setting that exchange property in the direct producer if
tracing is enabled as otherwise this will set it for everyone else when its not
really needed
{code}
Yes, I will do it accordingly.
Best Regards
Freeman
was (Author: ffang):
Hi [~davsclaus],
The exception
{code}
Failed to close span scope. This exception is ignored.
{code}
exists even without my changes when async mode is used here.
And it comes from the code
{code}
} else if (event instanceof
CamelEvent.ExchangeAsyncProcessingStartedEvent eap) {
// no need to filter scopes here. It's ok to close a scope
multiple times and
// implementations check if the scope being disposed is
current
// and should not do anything if scopes don't match.
ActiveSpanManager.endScope(eap.getExchange());
}
{code}
If I read comments here correctly, this is by design.
{code}
// no need to filter scopes here. It's ok to close a scope
multiple times and
// implementations check if the scope being disposed is
current
// and should not do anything if scopes don't match.
{code}
If we close the scope already in the expected thread, it should be OK to close
it again in another thread, and that's why we see this exception and can ignore
it. And as long as we close the scope already in the expected thread, there
would be no context leak.
Best Regards
Freeman
> camel-opentelemetry context leak with direct async producer
> -----------------------------------------------------------
>
> Key: CAMEL-21302
> URL: https://issues.apache.org/jira/browse/CAMEL-21302
> Project: Camel
> Issue Type: Bug
> Components: camel-opentelemetry
> Reporter: John Poth
> Assignee: Freeman Yue Fang
> Priority: Major
> Fix For: 4.9.0
>
>
> There seems to be a Otel context leak when using a CXF producer in async
> mode. This causes different requests to have the same _traceId._ As a
> workaround, setting _synchronous=true_ on the CXF producer resolves the
> issue. Here's a reproducer:
> {code:java}
> @Override
> protected RoutesBuilder createRouteBuilder() {
> return new RouteBuilder() {
> @Override
> public void configure() {
> from("direct:start").routeId("myRoute")
> .to("direct:send")
> .end();
> from("direct:send")
> .log("message")
> .to("cxfrs:http://localhost:" + port1
> + "/rest/helloservice/sayHello?synchronous=false");
> // setting to 'true' resolves the issue
> restConfiguration()
> .port(port1);
> rest("/rest/helloservice")
> .post("/sayHello").routeId("rest-GET-say-hi")
> .to("direct:sayHi");
> from("direct:sayHi")
> .routeId("mock-GET-say-hi")
> .log("example")
> .to("mock:end");
> }};
> {code}
>
> I've added the complete unit here:
> https://github.com/apache/camel/blob/7d83a62b8e442dc9ac6fd79b153192add940301e/components/camel-opentelemetry/src/test/java/org/apache/camel/opentelemetry/AsyncCxfTest.java
--
This message was sent by Atlassian Jira
(v8.20.10#820010)