Java APM Client: transfer transaction information when using BlockingQueue instead of ExecutorService

Thanks a lot!
The approach works well in both cases, while transferring the span and transaction.

Regarding other thread, for me definition of detaching is running application as if agent was never connected to it. Free all the resources it capture upon attachment. Also there could be chances that some instrumentation plugins not using active flag. Though setting active to false will not report to APM Server we can still see instrumentation happening is such cases in the apm log.
I have observed that JMS plugin isn't using active flag and instrumenting the calls irrespective of the value of active flag. JMS instrumentation stops only when we set value for ElasticApmInstrumentation.tracer to null. Might need to raise issue on GIT to fix that.

Now I am using reflection to access the ElasticApmInstrumentation class from agent and using public API for instrumenting internal calls.
Performing following actions as part of dettachment.

  • set active flag to false;
  • invoke ElasticApmInstrumentation.tracer.stop()
  • set value for ElasticApmInstrumentation.tracer to null.