ApmScopeManager.active() is returning scope with finishSpanOnClose always set to false
See original GitHub issueDescribe the bug Based on the code: https://github.com/elastic/apm-agent-java/blob/master/apm-opentracing/src/main/java/co/elastic/apm/opentracing/ApmScopeManager.java#L58-L67, when the app gets the current active scope from APM tracer like this:
Scope scope = tracer.scopeManager().active();
the returned scope
object always has finishSpanOnClose
set to false, if we close the scope, the current span inside scope is not finished.
This is causing spans created by opentracing/java-spring-messaging being dropped.
To Reproduce This issue can be simply reproduced by debugging the below snippet:
Tracer tracer = new ElasticApmTracer();
tracer.buildSpan("test")
.startActive(true);
Scope scope = tracer.scopeManager().active();
// verify that finishSpanOnClose is false.
scope.close();
Or it can be reproduced end-to-end by having a spring-cloud-stream app with opentracing/java-spring-messaging. The spans produced by the library is not shipped to Elastics.
Expected behaviour
tracer.scopeManager().active()
returns a Scope
object that preserves the finishSpanOnClose
config from current active scope.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (6 by maintainers)
Top GitHub Comments
@felixbarny : you are right, thanks for pointing that out!
@eyalkoren : sorry for wasting your time for supporting deprecated methods. I’ll create an PR to update java-spring-messaging instead.
@jzhn please note we will not merge the PR referenced above. Did you create a PR for stop using the deprecated API?