From 37c1767b06dd9c80beef093565cd145914f614aa Mon Sep 17 00:00:00 2001 From: Dragisa Krsmanovic Date: Fri, 11 Feb 2022 14:18:58 -0800 Subject: [PATCH] Similar to ConsumerSettings.withClientId, add withClientId to ProducerSettings --- core/src/main/scala/akka/kafka/ProducerSettings.scala | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/main/scala/akka/kafka/ProducerSettings.scala b/core/src/main/scala/akka/kafka/ProducerSettings.scala index 82639757d..3fe54c2b6 100644 --- a/core/src/main/scala/akka/kafka/ProducerSettings.scala +++ b/core/src/main/scala/akka/kafka/ProducerSettings.scala @@ -242,6 +242,13 @@ class ProducerSettings[K, V] @InternalApi private[kafka] ( ) def producerFactory: ProducerSettings[K, V] => Producer[K, V] = _ => createKafkaProducer() + /** + * An id string to pass to the server when making requests. The purpose of this is to be able to track the source + * of requests beyond just ip/port by allowing a logical application name to be included in server-side request logging. + */ + def withClientId(clientId: String): ProducerSettings[K, V] = + withProperty(ProducerConfig.CLIENT_ID_CONFIG, clientId) + /** * A comma-separated list of host/port pairs to use for establishing the initial connection to the Kafka cluster. */