feat(dsm): add kafka_cluster_id to segmentio/kafka-go integration#4477
Conversation
Plumb Kafka cluster ID through the DSM pipeline so that offsets and checkpoints from different clusters are distinguishable. For confluent-kafka-go, the cluster ID is fetched automatically via the AdminClient API; other Kafka libraries pass empty string for now and will be wired in follow-up PRs. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add cluster ID as a span tag on produce and consume spans, add ext constant MessagingKafkaClusterID, and add integration test verifying cluster ID flows into spans, DSM pathway hashes, and backlog tags. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Auto-fetched cluster ID from the Kafka admin API is now prepended to options so that user-provided WithClusterID takes precedence. Also fix TestConsumerFunctional pathway hash to account for auto-fetched cluster ID in integration test environments. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The TestConsumerFunctional test was computing expected pathway hashes without the kafka_cluster_id tag, but the production code now includes it after auto-fetching from the broker. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
76111c5 to
7d0d2b3
Compare
BenchmarksBenchmark execution time: 2026-03-20 04:19:21 Comparing candidate commit 28e8a60 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 216 metrics, 8 unstable metrics.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files🚀 New features to boost your workflow:
|
Avoid repeated admin API calls to fetch cluster ID when creating multiple consumers/producers to the same Kafka cluster. The cache is shared between v1 and v2 packages via kafkatrace. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
7d0d2b3 to
4c9fc7d
Compare
Remove the public WithClusterID option function which was only used internally and for testing. Set cluster ID directly on the tracer after wrapping instead. Also reduce cluster ID fetch timeout from 10s to 2s. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Move cluster ID fetching to a background goroutine so it doesn't block Consumer/Producer creation. Protect the clusterID field with a RWMutex for safe concurrent access. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Move cluster ID goroutine lifecycle into the Tracer via FetchClusterIDAsync/WaitForClusterID. Close() waits for the goroutine to prevent use-after-free of the librdkafka handle. Tests call WaitForClusterID before producing/consuming to ensure deterministic pathway hashes. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
68e76bf to
3ed2642
Compare
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 28e8a60 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
52c3314 to
01f3ee5
Compare
6dcd1dc to
f98f0a4
Compare
ac5efc0 to
e39a9ab
Compare
… TrackKafkaProduceOffsetWithCluster params FetchClusterIDAsync now accepts a cancellable context so Close() can signal the fetch to stop early rather than blocking unconditionally. Also reorders TrackKafkaProduceOffsetWithCluster params to match the Kafka hierarchy: cluster, topic, partition, offset. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
f98f0a4 to
e916411
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Replace duplicated cluster ID fetching, caching, and normalization code with the shared instrumentation/kafkaclusterid package. Use context-aware FetchAsync for cancellation support on Close. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
… ID impl Replace the kafkaclusterid.Fetcher with a simple mutex-guarded string matching the confluent-kafka-go pattern. Fix TrackKafkaCommitOffsetWithCluster argument order. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
e39a9ab to
1776bdc
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
b706da3 to
89413af
Compare
kafka.TCP expects variadic individual addresses, not a single comma-separated string. Passing one string causes a network/address array length mismatch in kafka-go's transport.go Shuffle, panicking with index out of range. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
0d976d2 to
783bddd
Compare
Add require.Eventually to genIntegrationTestSpans to wait for the async cluster ID fetch to complete, matching the confluent-kafka-go test pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
783bddd to
443d973
Compare
genesor
left a comment
There was a problem hiding this comment.
Looks great! I have one quick comment about the mutex.
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
## Summary - This follows practically the same pattern as the [confluent-kafka-go](#4470) and [kafka-go](#4477) PRs. However, this integration requires the user to supply the bootstrap servers explicitly in order to obtain the cluster id. - Adds `WithBrokers` option to both IBM/sarama and Shopify/sarama integrations that fetches the Kafka cluster ID via a metadata request and includes it in DSM payloads (DSM only) - Tested manually and via unit / integration tests. Co-authored-by: genesor <[email protected]> Co-authored-by: rob.carlan <[email protected]>
Summary
kafka_cluster_idsupport to thesegmentio/kafka-goDSM integration, building on feat(dsm): add kafka_cluster_id to confluent-kafka-go #4470WrapReader/WrapWriterTested this manually and via unit/integration tests.