Elastic Java Agent unable to capture Kafka traces with Custom Threadpool

Hi,

I am using Java elastic APM agent version 1.36 with my kafka based application.
The Kafka based application uses custom thread pool which is developed by using LinkedBlockingQueue for holding tasks.
However, I am unable to get the kafka traces of the class that behaves as a Task for the worked threads. This task holds the logic to send messages to the kafka server.
The same works when Java's inbuilt executor framework is used instead of custom threadpool.

The executor framework is supported by the apm agent is known to me but in case of custom threadpool implementations , Are the traces not captured?

I also tried to add the Task.java class of my sample application in the trace_methods property but still unable to get the traces captured.

Is there any other way to get the trace captured? Please advise.

Thanks & Regards,
Namita Jaokar

You'll need to manually propagate the tracing context in your custom executor:

When a task is added to your executor, you'll need to "remember" the currently active span for that task obtained via ElasticAPM.currentSpan().

When you start executing the task (on the different thread), you'll need to activate the remembered span.

Thanks @Jonas_Kunz for the suggestion. Is there any way it can be handled in the elastic agent jar ?

Best Regards,
Namita

Hi @Jonas_Kunz , Is there any example I can refer to for implementing the same.

Best Regards,
Namita Jaokar

Is there any way it can be handled in the elastic agent jar ?

You could wirte a custom plugin.

Is there any example I can refer to for implementing the same

I don't think so, you'll have to rely on the public API docs.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.