Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

Appd tocbox

On This Page:

Table of Contents

You can configure the AppDynamics Java Agent to detect entry points for following Apache Kafka consumer activity :


using KafkaConsumer.poll()


(introduced in Kafka v0.


10) or Kafka Streams


and Kafka


SimpleConsumer.fetch()(both introduced in Kafka v0.


Because 9).

Prior to version 0.11, the Kafka payload doesn't did not include a location to store correlation data, the Java Agent detects consumer activity downstream from Kafka as a new business transaction.so end-to-end Business Transaction correlation is only possible with Kafka client and broker versions 0.11 or greater.

KafkaConsumer.poll and Kafka Stream Entry Points

To instrument Kafka consumer exit entry points using KafkaConsumer.poll() or Kafka Streams, identify the method where the consumer reads messages in a loop in a custom interceptor definition. We instrument the iterator's next method to start and end the BT for each message. There could be many iterators used for iterating messages but we only support iterators that are of type:

  • kafka.consumer.ConsumerIterator
  • org.apache.kafka.clients.consumer.ConsumerRecords$ConcatenatedIterable$1
  1. Identify the class and method of the loop that processes messages from Kafka. Consider for example a class MyConsumer that employs the following loop to poll and process messages from Kafka:

    Code Block
    private void pollMessages() throws Exception {
       ConsumerRecords<String, String> records = kafkaConsumer.poll(1000);
       for (ConsumerRecord<String, String> record : records) {
          //Processing of the records

    For this case, you want to intercept:

    • Class: MyConsumer
    • Method: pollMessages
  2. Use your preferred text editor to create and edit a file named custom-interceptors.xml at the following path:

    For example:
  3. Copy the following XML to custom-interceptors.xml:

    No Format
            <match-class type="matches-class">
                <name filter-type="equals">my-fully-qualified-class-name</name>
  4. Set the value of the class name to the name of your consumer class. For instance, to specify the MyConsumer class:

    No Format
    <match-class type="matches-class">
        <name filter-type="equals">com.mycompany.mypackage.MyConsumer</name>
  5. Set the value of the method name to the name of your message processing loop method. For instance, to specify the pollMessages method:

    No Format

    After the Java Agent reads the updated configuration, it detects consumer activity and upstream Kafka queue. The application flow map shows the tier receiving data from the Kafka queue. The Kafka queue does not appear on the BT level flow map.



Kafka consumer activity shows up as an exit call in in this case.