Skip to content

Commit

Permalink
Make the internal RefreshFrequency of sarama to match the flag value
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgelbg committed Nov 14, 2018
1 parent d7385e4 commit b2b95d1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,21 @@ func NewExporter(opts kafkaOpts, topicFilter string, groupFilter string) (*Expor
zookeeperClient, err = kazoo.NewKazoo(opts.uriZookeeper, nil)
}

client, err := sarama.NewClient(opts.uri, config)

interval, err := time.ParseDuration(opts.metadataRefreshInterval)
if err != nil {
plog.Errorln("Error Init Kafka Client")
plog.Errorln("Cannot parse refresh metadata interval")
panic(err)
}
plog.Infoln("Done Init Clients")

interval, err := time.ParseDuration(opts.metadataRefreshInterval)
config.Metadata.RefreshFrequency = interval

client, err := sarama.NewClient(opts.uri, config)

if err != nil {
plog.Errorln("Cannot parse refresh metadata interval")
plog.Errorln("Error Init Kafka Client")
panic(err)
}
plog.Infoln("Done Init Clients")

// Init our exporter.
return &Exporter{
Expand Down Expand Up @@ -226,6 +228,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
offset := make(map[string]map[int32]int64)

now := time.Now()

if now.After(e.nextMetadataRefresh) {
plog.Info("Refreshing client metadata")

Expand Down

0 comments on commit b2b95d1

Please sign in to comment.