How to disable instrumentation just for kafka producers (but not consumers) on APM java agent

Hi,
I now I can disable instrumentation for kafka events with disable_instrumentations property like this:

disable_instrumentations=kafka

But this removes all related to Kafka. I would like to disable instrumentation only when producing, but keep the consumers instrumented. The reason is because we have an app that produces tons of messages per every consumed message and we would like to focus instrumentation only on the consumer processes.

I think the responsible class of this is the following:

but I can't find any configuration related or a way to disable it.

Thanks!

Hi @spekdrum ,

As you have discovered, this is not something that can be fixed using configuration.

The agent capture two types of objects for Kafka

  • transactions when consuming a message (what you are interested in)
  • spans when sending messages within a transaction (what you want to filter out)

Thus here one possible work-around would be to use an ingestion filter on ES/APM server to remove the messaging spans: doc.

However, removing the "send message" spans means that the Transaction trace view will be broken as it relies on those intermediate spans for parent/child relationships. However, that might also work quite well if you use-case does not depends heavily on the traces view, for example if most of the application activity is handling messages by writing something to database and the delegation that you want to ignore isn't the main thing you want to monitor for now.