Public API using startTransactionWithRemoteParent for Kafka headers

APM Agent language and version: 1.38.0

We need to manually instrument our Kafka apps as Kafka streams is not supported yet by Elastic APM agent .

In order make the tracing work across all apps, we need to create transactions with remote parent.

How to create a transaction remote parent with kafka headers?

Above method seems to be specifically targeted for HTTP headers. How to do the same for Kafka headers?

It's unclear from the above link on how exactly the functional interface is defined and what needs to be the output of that method.


The HeaderExtractor interface is very generic, as you can see from that example it's really just any lambda that returns a string. So you can use that for anything, you just need to specify extracting the header from kafka

I was able to figure that out. But there are stil some issues:

  1. How to decode the byte array? I had to look at the open source code to figure this out : apm-agent-java/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/ at main · elastic/apm-agent-java · GitHub

Ideally we should not be writing our own decode() function to convert byte array into a hex string according to your specification. Is there any other way to do this? directly passing the byte array to your API?

  1. The argument passed to the functional interface doesn't match with the header key

Argument passed is "elastic-apm-traceparent" but the header is populated with "elasticapmtraceparent".

The TraceContext is internal to the agent, not part of the public API. For now you need to write your own decoder using that as a template. That should also resolve the header name since you'll be passing that

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