Skip to content

Commit

Permalink
add support for setting client ID
Browse files Browse the repository at this point in the history
  • Loading branch information
richardartoul committed Dec 20, 2023
1 parent 0c50ef5 commit c2f4c68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions exporter/kafkaexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ type Config struct {

// Metadata defines configuration for retrieving metadata from the broker.
type Metadata struct {
// ClientID to configure the Kafka client with. This can be leveraged by
// Kafka to enforce ACLs, throttling quotas, and more.
ClientID string `mapstructure:client_id`

// Whether to maintain a full set of metadata for all topics, or just
// the minimal set that has been necessary so far. The full set is simpler
// and usually more convenient, but can take up a substantial amount of
Expand Down
3 changes: 3 additions & 0 deletions exporter/kafkaexporter/kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ func (e *kafkaLogsProducer) Close(context.Context) error {

func newSaramaProducer(config Config) (sarama.SyncProducer, error) {
c := sarama.NewConfig()

c.ClientID = config.Metadata.ClientID

// These setting are required by the sarama.SyncProducer implementation.
c.Producer.Return.Successes = true
c.Producer.Return.Errors = true
Expand Down

0 comments on commit c2f4c68

Please sign in to comment.