concept monitoring in category kafka

This is an excerpt from Manning's book Kafka in Action.
One of the options when using the producer is creating producer interceptors. They were introduced in KIP-42 whose main design was to help support measurement and monitoring. It is true that you can modify the message and since the interceptor will run before a partition gets assigned, it is important to note any key changes. The client might not know what to expect if the key changes the partition assignment they intended. In comparison to Kafka Streams workflows, the usage of these interceptors might not be your first choice. Kafka also does report various internal metrics using JMX that can be used if monitoring is a main concern.
Let’s revisit the concept of interceptors that we touched on briefly in chapter 4 in introducing what producer interceptors could do for our messages. By adding an interceptor on both the producer and consumer clients that you are using, you can remove the monitoring logic from the application logic itself. The crosscutting concern of monitoring can hopefully be more encapsulated by this approach.