I have already created a Jira for this, but have not received any comments so bringing this to email.
https://issues.apache.org/jira/browse/KAFKA-6123 Interceptors and MetricsReporters configured for a client will receive the user-specified configurations via the configure() method. When a user does not specify the client.id field, Kafka will automatically generate a client id for the client (producer-1, producer-2, consumer-1, consumer-2, etc). This auto-generated client id is given to the interceptors in the configure method, but it is not given to the metric reporters configured for the client. This makes it hard to directly map a client's configured metrics reporters with the configured interceptors when the client.id field is not specified (you would have to fetch a MetricName object that has client id as a tag but that is hacky). The client.id field is already generated by the time the metrics reporters are configured. Is there a particular reason why the MetricsReporter does not also receive the auto-generated client id? If there are no issues with this suggestion, then I would love to work on this as my first commit! Regards, Kevin