fix: collect KafkaTopicSample on Kafka 4.x (DescribeConfigs version)#375
Merged
Merged
Conversation
Kafka 4.0 removed DescribeConfigs API v0 (the broker minimum is now v1), so the hardcoded v0 request used for topic and broker configuration collection failed against 4.x brokers. As a result KafkaTopicSample was dropped entirely, while KafkaBrokerSample/KafkaProducerSample/ KafkaConsumerSample/KafkaOffsetSample (JMX- and other-API-based) kept working - matching the reported "topic samples missing on Kafka 4.x". Derive the DescribeConfigs request version from the negotiated KAFKA_VERSION (v2 if >= 2.0.0, v1 if >= 1.1.0, else v0; sarama v1.43.x supports DescribeConfigs up to v2), and raise the default KAFKA_VERSION from 1.0.0 to 2.1.0 so topic and broker configuration collection works against Kafka 4.x out of the box with no user configuration. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1611e01 to
2f4e7d2
Compare
abhishuraina
approved these changes
Jun 23, 2026
abhishuraina
left a comment
Contributor
There was a problem hiding this comment.
LGTM, make sure you've tested it on kafka V4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
KafkaTopicSampleis missing on Kafka 4.x clusters whileKafkaBrokerSample,KafkaProducerSample,KafkaConsumerSample, andKafkaOffsetSamplecontinue to report.Root Cause: The integration issues
DescribeConfigsrequests at API version 0, which Kafka 4.0 removed (the broker's minimum supported version is now v1, per KIP-896). The v0 request is rejected by the broker,setTopicInfo()returns an error, andtopicWorker()continues before the topic metric set is created — so the topic sample is dropped entirely. Broker/producer/consumer/offset samples are JMX- or higher-level-API-based, so they remain unaffected.This was reproduced and verified on a real Kafka 3.8.1 (works) vs 4.0.0 (topic samples missing) cluster, confirmed both via the integration's
-prettyoutput and in NRDB.Changes
src/topic/topic_collection.go,src/broker/broker_collection.go: Derive theDescribeConfigsrequest version from the negotiatedKAFKA_VERSIONinstead of hardcoding 0.>= 2.0.0→v2,>= 1.1.0→v1, elsev0. (Sarama v1.43.x supportsDescribeConfigsup tov2; Kafka 4.0 supports 1–4).IncludeSynonymsis now set only when the version supports it (>= 1).src/args/args.go: Raise the defaultKAFKA_VERSIONfrom1.0.0to2.1.0. This ensures topic/broker config collection works against Kafka 4.x out of the box without requiring manual user configuration.src/args/args_test.go: UpdatedTestDefaultArgsexpectation to match the new default.CHANGELOG.md: Added unreleased bug-fix entry.Why both changes are needed
Sarama refuses to send a request whose
requiredVersion()exceedsconfig.Version(withinbroker.go). Simply fixing the hardcoded version is insufficient; with the old1.0.0default, av2(or evenv1) request is rejected client-side. Bumping the default ensures functionality for Kafka 4.x users without forcing manual configuration changes. Deriving the version (rather than hardcodingv2) ensures we do not regress support for genuinely older brokers.Testing
go test ./src/...passes.KafkaTopicSample = 0,DescribeConfigserrors.KAFKA_VERSIONset):KafkaTopicSamplepresent for all topics, 0DescribeConfigserrors; confirmed in NRDB.Compatibility / Notes
2.1.0), which negotiates down per-API viaApiVersions.KAFKA_VERSIONnon-fatal (falling back to default instead of aborting the whole run).