You can create a child span in the onMessage
method and hand that over to the disruptor. In the EventHandler, you can set the start timestamp and the name of that span and activate it. See also https://github.com/elastic/apm-agent-java/blob/master/apm-agent-plugins/apm-api-plugin/src/test/java/co/elastic/apm/api/BlockingQueueContextPropagationTest.java
If you really wanted to have two distinct transactions, you can also transfer the context to a map (span.injectTraceHeaders((name, value) -> map.put(name, value))
) which you can hand over to the disruptor. In the EventHandler, you can then do ElasticApm.startTransactionWithRemoteParent(key -> map.getHeader(key))
.
In your other thread, I'd also be interested to hear why having the agent threads around when active=false
is a problem for your use case.