Skip to content
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

Add caching for the topics metadata #75

Merged
merged 4 commits into from
Jan 31, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make it compile with Go v1.11 and fix formatting issue
  • Loading branch information
jorgelbg committed Nov 13, 2018
commit 05e8aac6023242d79d660ce58e1f425502c6fa0e
9 changes: 5 additions & 4 deletions kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strconv"
"strings"
"sync"

"github.com/Shopify/sarama"
kazoo "github.com/krallistic/kazoo-go"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -41,7 +42,7 @@ var (
consumergroupCurrentOffsetSum *prometheus.Desc
consumergroupLag *prometheus.Desc
consumergroupLagSum *prometheus.Desc
consumergroupLagZookeeper *prometheus.Desc
consumergroupLagZookeeper *prometheus.Desc
consumergroupMembers *prometheus.Desc
)

Expand Down Expand Up @@ -387,7 +388,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
for partition, offsetFetchResponseBlock := range partitions {
err := offsetFetchResponseBlock.Err
if err != sarama.ErrNoError {
plog.Errorln("Error for partition %d :%v", partition, err.Error())
plog.Errorf("Error for partition %d :%v", partition, err.Error())
continue
}
currentOffset := offsetFetchResponseBlock.Offset
Expand All @@ -410,7 +411,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
consumergroupLag, prometheus.GaugeValue, float64(lag), group.GroupId, topic, strconv.FormatInt(int64(partition), 10),
)
} else {
plog.Errorln("No offset of topic %s partition %d, cannot get consumer group lag", topic, partition)
plog.Errorf("No offset of topic %s partition %d, cannot get consumer group lag", topic, partition)
}
e.mu.Unlock()
}
Expand Down Expand Up @@ -555,7 +556,7 @@ func main() {
"Current Approximate Lag of a ConsumerGroup at Topic/Partition",
[]string{"consumergroup", "topic", "partition"}, labels,
)

consumergroupLagZookeeper = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "consumergroupzookeeper", "lag_zookeeper"),
"Current Approximate Lag(zookeeper) of a ConsumerGroup at Topic/Partition",
Expand Down