Skip to content

Produce deterministic "client.id" by default#5308

Open
Konstantin Demin (rockdrilla) wants to merge 5 commits intoconfluentinc:masterfrom
rockdrilla:default-client-id
Open

Produce deterministic "client.id" by default#5308
Konstantin Demin (rockdrilla) wants to merge 5 commits intoconfluentinc:masterfrom
rockdrilla:default-client-id

Conversation

@rockdrilla

It's no secret that many applications don't set client.id themselves, making identification on the Kafka broker difficult.

The problem becomes more acute when applications run in container orchestration environments (Kubernetes, Nomad, Docker, etc.) and connect to external Kafka clusters. In such cases, identifying the actual producer/consumer instance becomes nearly impossible without a meaningful client.id.

This MR addresses the issue by providing a deterministic default client.id in the form "rdkafka@{hostname}", falling back to the previous default "rdkafka" if the hostname cannot be retrieved.

A quick note on intent:
This MR isn't meant to call out or blame any specific software or project for not setting client.id. Many legitimate use cases rely on defaults, and the goal here is simply to make those defaults more useful for operational visibility - especially in modern cloud-native environments. The change is proposed as a general improvement to librdkafka's out-of-the-box experience.


Nota bene:

This MR consists of two logical parts:

Part 1: Non-breaking improvements (safe to merge)

  • Define RD_NOINLINE as opposite to RD_INLINE
  • Ensure rd_kafka_transport_init() is called once
  • Adjust buffer size to avoid hostname truncation (applies to example application)

Part 2: Potentially breaking change (requires discussion)

  • Produce deterministic "client.id" by default
  • Adjust "client.id" in examples and tests

Regarding CHANGELOG.md: I believe these changes should be part of the next release (e.g., 2.14.0). If accepted, I can update the changelog with something like:

  • Ensure Winsock initialization is called only once via InitOnceExecuteOnce
  • Add deterministic default client.id (rdkafka@{hostname}) when none is provided

Thoughts? Feedback welcome!

This allows to mark functions to not be inlined even if compiler decides that inlining is possible.

Signed-off-by: Konstantin Demin <[email protected]>
This change will raise minimum requirements for Windows builds due to InitOnceExecuteOnce() usage: Windows Vista / Windows Server 2008 are minimum supported systems.

Signed-off-by: Konstantin Demin <[email protected]>
Also initialize buffer with zeros (with good intentions).

Signed-off-by: Konstantin Demin <[email protected]>
Set "client.id" to "rdkafka@{hostname}" and fallback to "rdkafka" (previous default value) if there're problems with retrieving current host name.

Signed-off-by: Konstantin Demin <[email protected]>
@confluent-cla-assistant
Copy link

confluent-cla-assistant bot commented Feb 13, 2026

🎉 All Contributor License Agreements have been signed. Ready to merge.
✅ rockdrilla
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant