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 inactive consumer case #48

Merged
merged 1 commit into from
Nov 15, 2017
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion kafka/parsing.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ var (
// Parser for Kafka 0.10.2.1. Since we are unsure if the column widths are dynamic, we are using `\s+` for delimiters.
kafka0_10_2_1DescribeGroupParser = mustBuildNewRegexpParser(
regexp.MustCompile(`TOPIC\s+PARTITION\s+CURRENT-OFFSET\s+LOG-END-OFFSET\s+LAG\s+CONSUMER-ID\s+HOST\s+CLIENT-ID`),
regexp.MustCompile(`(?P<topic>[a-zA-Z0-9\\._\\-]+)\s+(?P<partitionId>\d+|-)\s+(?P<currentOffset>\d+|-)\s+(\d+|-)\s+(?P<lag>\d+|-)\s+(?P<consumerId>\S+)\s*/(?P<consumerAddress>\S+)\s+(?P<clientId>\S+)`),
regexp.MustCompile(`(?P<topic>[a-zA-Z0-9\\._\\-]+)\s+(?P<partitionId>\d+|-)\s+(?P<currentOffset>\d+|-)\s+(\d+|-)\s+(?P<lag>\d+|-)\s+(?P<consumerId>[^/\s]+)\s*/?(?P<consumerAddress>\S+)\s+(?P<clientId>\S+)`),
)

// Parser for Kafka 0.10.1.X.
Expand Down
27 changes: 27 additions & 0 deletions kafka/parsing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,33 @@ topic3 0 45 45 0 consumer
})
}

func TestParsingPartitionTableWithMissingValuesConsumerIdForKafkaVersion0_10_2_1(t *T) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for tests. Thanks!

output := CommandOutput{
Stderr: "NOTE: When there is no active consumer CONSUMER_ID, HOST and CLIENT-ID is -\n",
Stdout: `
TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID
TEST 0 109 134 25 - - -`,
}

expected := []exporter.PartitionInfo{
{
Topic: "TEST",
PartitionID: "0",
CurrentOffset: 109,
Lag: 25,
ClientID: "-",
ConsumerAddress: "-",
},
}

t.Run("kafka0_10_2_1DescribeGroupParser", func(t *T) {
comparePartitionTable(t, kafka0_10_2_1DescribeGroupParser, output, expected)
})
t.Run("DefaultDescribeGroupParser", func(t *T) {
comparePartitionTable(t, DefaultDescribeGroupParser(), output, expected)
})
}

func TestParsingPartitionTableWithMissingValuesForKafkaVersion0_10_2_1(t *T) {
output := CommandOutput{
Stderr: "Note: This will only show information about consumers that use the Java consumer API (non-ZooKeeper-based consumers).\n",
Expand Down