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

fix: offsetFetchResponse missing topic partitions #432

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Changes from all commits
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
24 changes: 12 additions & 12 deletions kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,17 @@ func NewExporter(opts kafkaOpts, topicFilter string, topicExclude string, groupF
}, nil
}

//func (e *Exporter) fetchOffsetVersion() int16 {
// version := e.client.Config().Version
// if e.client.Config().Version.IsAtLeast(sarama.V2_0_0_0) {
// return 4
// } else if version.IsAtLeast(sarama.V0_10_2_0) {
// return 2
// } else if version.IsAtLeast(sarama.V0_8_2_2) {
// return 1
// }
// return 0
//}
func (e *Exporter) fetchOffsetVersion() int16 {
version := e.client.Config().Version
if e.client.Config().Version.IsAtLeast(sarama.V2_0_0_0) {
return 4
} else if version.IsAtLeast(sarama.V0_10_2_0) {
return 2
} else if version.IsAtLeast(sarama.V0_8_2_2) {
return 1
}
return 0
}

// Describe describes all the metrics ever exported by the Kafka exporter. It
// implements prometheus.Collector.
Expand Down Expand Up @@ -574,7 +574,7 @@ func (e *Exporter) collect(ch chan<- prometheus.Metric) {
klog.Errorf("Cannot describe for the group %s with error code %d", group.GroupId, group.Err)
continue
}
offsetFetchRequest := sarama.OffsetFetchRequest{ConsumerGroup: group.GroupId, Version: 1}
offsetFetchRequest := sarama.OffsetFetchRequest{ConsumerGroup: group.GroupId, Version: e.fetchOffsetVersion()}
if e.offsetShowAll {
for topic, partitions := range offset {
for partition := range partitions {
Expand Down
Loading