Skip to content

Commit 01f3ee5

Browse files
refactor(dsm): remove WithClusterID option from kafka-go
Remove the public WithClusterID option since cluster ID is now auto-detected. Add Close() to KafkaWriter to wait for async fetch. Add WaitForClusterID calls in test helper for deterministic behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3ed2642 commit 01f3ee5

4 files changed

Lines changed: 8 additions & 13 deletions

File tree

contrib/segmentio/kafka-go/internal/tracing/tracer.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,6 @@ func WithDataStreams() Option {
9696
})
9797
}
9898

99-
// WithClusterID sets the Kafka cluster ID for Data Streams monitoring and span tagging.
100-
// This overrides the automatically detected cluster ID.
101-
func WithClusterID(clusterID string) Option {
102-
return OptionFn(func(tr *Tracer) {
103-
tr.kafkaCfg.ClusterID = clusterID
104-
})
105-
}
106-
10799
func (tr *Tracer) ClusterID() string {
108100
tr.clusterIDMu.RLock()
109101
defer tr.clusterIDMu.RUnlock()

contrib/segmentio/kafka-go/kafka.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ func parseAddrs(addr net.Addr) []string {
178178
return strings.Split(addr.String(), ",")
179179
}
180180

181+
// Close calls the underlying Writer.Close.
182+
func (w *KafkaWriter) Close() error {
183+
w.tracer.WaitForClusterID()
184+
return w.Writer.Close()
185+
}
186+
181187
// WriteMessages calls kafka-go.Writer.WriteMessages and traces the requests.
182188
func (w *KafkaWriter) WriteMessages(ctx context.Context, msgs ...kafka.Message) error {
183189
// although there's only one call made to the SyncProducer, the messages are

contrib/segmentio/kafka-go/kafka_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,13 @@ func genIntegrationTestSpans(t *testing.T, mt mocktracer.Tracer, writerOp func(t
162162
writtenMessages = append(writtenMessages, messages...)
163163
}
164164
w := WrapWriter(kw, writerOpts...)
165+
w.tracer.WaitForClusterID()
165166
writerOp(t, w)
166167
err := w.Close()
167168
require.NoError(t, err)
168169

169170
r := WrapReader(testReader(), readerOpts...)
171+
r.tracer.WaitForClusterID()
170172
readerOp(t, r)
171173
err = r.Close()
172174
require.NoError(t, err)

contrib/segmentio/kafka-go/option.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,3 @@ func WithDataStreams() Option {
3434
return tracing.WithDataStreams()
3535
}
3636

37-
// WithClusterID sets the Kafka cluster ID for Data Streams monitoring and span tagging.
38-
// This overrides the automatically detected cluster ID.
39-
func WithClusterID(clusterID string) Option {
40-
return tracing.WithClusterID(clusterID)
41-
}

0 commit comments

Comments
 (0)