-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Use application name as default clientId #3001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@notizklotz I think we should still preserve |
Note: the The "producer", "consumer" and "adminclient" comes from bean names auto-configured for those specific Kafka clients. We may indeed consider to include
And somewhere there we can resolve it like |
I started implementing a proof of concept and it seems to work out well, especially for the cases which currently have a very generic clientId (Consumer without Consumer Group, Producer, Admin Client). I chose to put the application name before the type ( The following table with examples assumes
|
Thank you for investigation! So, as we have discussed before, we have a plan. Does that makes sense? |
@artembilan Yes, that makes sense :-) The code of my PoC is here and I could work it into a proper PR within the next weeks: main...notizklotz:spring-kafka:GH-3001 |
Very nice proposal. I'm currently facing the same issue. When deploying in a cloud environment like Kubernetes, the same client id may still refer to multiple instances of a producer, consumer and admin client. So, to solve this issue, wouldn't it make sense to have a ClientIdResolver with a default implementation referring to what has been proposed above? The resolver contract would be as follow
The resolver would also avoid the resolution of the clientId in 3 different kind of clients... Users deploying in a cloud would be able to provide another implementation adding the pod id or another relevant information to enable correlation between the clientId and a specific instance of the producer, consumer and admin client. Hope that the proposal make sense and can help investigations based on the clientId when deploying in a cloud environment. |
As far as I know you can use env vars placeholders in those Spring Boot configuration properties, therefore no need in extra logic in the code: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.external-config.files.property-placeholders |
Fair point. The idea was also to factorize the code to avoid duplicating the same logic in 3 different places, allowing to change the resolution in an easy way. Thanks for the quick reply. |
@notizklotz Please let us know when you can work on a PR. We are postponing this issue to the next milestone ( |
Fixes: #spring-projectsGH-3001 Use Spring Boot's `spring.application.name` property as part of the default clientIds for Consumers, Producers and AdminClients. Helps with identifying problematic clients at server side. * Only use as a fallback if clientId wasn't specified explicitly * Do not use for Consumers with a specified groupId because KafkaConsumer will use the groupId as clientId which already is an identifiable default
@sobychacko I have the PR ready: #3048 |
# Conflicts: # spring-kafka-docs/src/main/antora/modules/ROOT/pages/whats-new.adoc
Fixes: #spring-projectsGH-3001 Use Spring Boot's `spring.application.name` property as part of the default clientIds for Consumers, Producers and AdminClients. Helps with identifying problematic clients at server side. * Only use as a fallback if clientId wasn't specified explicitly * Do not use for Consumers with a specified groupId because KafkaConsumer will use the groupId as clientId which already is an identifiable default
Fixes: #spring-projectsGH-3001 Use Spring Boot's `spring.application.name` property as part of the default clientIds for Consumers, Producers and AdminClients. Helps with identifying problematic clients at server side. * Only use as a fallback if clientId wasn't specified explicitly * Do not use for Consumers with a specified groupId because KafkaConsumer will use the groupId as clientId which already is an identifiable default
Fixes: #GH-3001 * Use Spring Boot's `spring.application.name` property as part of the default clientIds for Consumers, Producers, and AdminClients. Helps with identifying problematic clients on the server side. * Only use as a fallback if clientId wasn't specified explicitly * Do not use for Consumers with a specified groupId because KafkaConsumer will use the groupId as clientId, which already is an identifiable default
Uh oh!
There was an error while loading. Please reload this page.
Expected Behavior
If
spring.application.name
is defined, it should be used as default Kafka clientId unless overriden by more specific configs. I get the behaviour that I think would be a good default by defining this in my application:spring.kafka.client-id=${spring.application.name}
Current Behavior
The default clientIds are "producer", "adminclient", etc.
Context
We operate fairly large shared Kafka clusters and a couple of important metrics and log output by Kafka only includes the clientId and not the username. Especially for producers this means we see many of our customers implicitly connecting using "producer-1" as clientId as there is no way on Kafka server side to enforce a specific pattern. By using a more specific default this would ease problem analysis on server side.
spring.application.name
would be an ideal default because this is also used for similar use cases with other technologies.I could have a look at creating a pull request for this, if this isn't something that has already been rejected in the past.
The text was updated successfully, but these errors were encountered: