On This Page:
On This Page:
- Kafka v0.10
- Kafka v0.9 Kafka Streams
- Kafka v0.9
KafkaConsumer.poll and Kafka Stream Entry Points
To instrument Kafka consumer 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:
Identify the class and method of the loop that processes messages from Kafka. Consider for example a class
MyConsumerthat employs the following loop to poll and process messages from Kafka:
For this case, you want to intercept:
- Use your preferred text editor to create and edit a file named custom-interceptors.xml at the following path:
Copy the following XML to custom-interceptors.xml:
Set the value of the class name to the name of your consumer class. For instance, to specify the
Set the value of the method name to the name of your message processing loop method. For instance, to specify the
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.
Kafka SimpleConsumer Entry Points
To enable consumer entry points for Kafka clients that retrieve messages using
SimpleConsumer.fetch(), register the
enable-kafka-consumer node property with a value of "true".
Kafka consumer activity shows up as an exit call in this case.