Skip to content

Commit 2e8c459

Browse files
piochelepiotrclaude
andcommitted
Update test assertions for new Kafka span tags
Add assertions for messaging.kafka.cluster.id, partition, and offset tags that are now set on producer and consumer spans. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f2a32a7 commit 2e8c459

7 files changed

Lines changed: 34 additions & 9 deletions

File tree

dd-java-agent/instrumentation/kafka/kafka-clients-0.11/src/latestDepTest/groovy/KafkaClientTestBase.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ abstract class KafkaClientTestBase extends VersionedNamingTestBase {
302302
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
303303
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)
304304
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$SHARED_TOPIC"
305-
if (partitioned) {
306-
"$InstrumentationTags.PARTITION" { it >= 0 }
307-
}
305+
"$InstrumentationTags.PARTITION" { it >= 0 }
306+
"$InstrumentationTags.OFFSET" { it >= 0 }
307+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
308308
if (tombstone) {
309309
"$InstrumentationTags.TOMBSTONE" true
310310
}
@@ -381,6 +381,7 @@ abstract class KafkaClientTestBase extends VersionedNamingTestBase {
381381
"$InstrumentationTags.OFFSET" { offset.containsWithinBounds(it as int) }
382382
"$InstrumentationTags.CONSUMER_GROUP" "sender"
383383
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG)
384+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
384385
"$InstrumentationTags.RECORD_QUEUE_TIME_MS" { it >= 0 }
385386
"$InstrumentationTags.RECORD_END_TO_END_DURATION_MS" { it >= 0 }
386387
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$SHARED_TOPIC"

dd-java-agent/instrumentation/kafka/kafka-clients-0.11/src/test/groovy/KafkaClientTestBase.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,9 +1205,9 @@ abstract class KafkaClientTestBase extends VersionedNamingTestBase {
12051205
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
12061206
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)
12071207
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$SHARED_TOPIC"
1208-
if (partitioned) {
1209-
"$InstrumentationTags.PARTITION" { it >= 0 }
1210-
}
1208+
"$InstrumentationTags.PARTITION" { it >= 0 }
1209+
"$InstrumentationTags.OFFSET" { it >= 0 }
1210+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
12111211
if (tombstone) {
12121212
"$InstrumentationTags.TOMBSTONE" true
12131213
}
@@ -1284,6 +1284,7 @@ abstract class KafkaClientTestBase extends VersionedNamingTestBase {
12841284
"$InstrumentationTags.OFFSET" { offset.containsWithinBounds(it as int) }
12851285
"$InstrumentationTags.CONSUMER_GROUP" "sender"
12861286
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG)
1287+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
12871288
"$InstrumentationTags.RECORD_QUEUE_TIME_MS" { it >= 0 }
12881289
"$InstrumentationTags.RECORD_END_TO_END_DURATION_MS" { it >= 0 }
12891290
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$SHARED_TOPIC"

dd-java-agent/instrumentation/kafka/kafka-clients-0.11/src/test/groovy/KafkaReactorForkedTest.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ class KafkaReactorForkedTest extends InstrumentationSpecification {
193193
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
194194
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)
195195
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$KafkaClientTestBase.SHARED_TOPIC"
196+
"$InstrumentationTags.PARTITION" { it >= 0 }
197+
"$InstrumentationTags.OFFSET" { it >= 0 }
198+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
196199
peerServiceFrom(InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS)
197200
defaultTags()
198201
}
@@ -222,6 +225,7 @@ class KafkaReactorForkedTest extends InstrumentationSpecification {
222225
"$InstrumentationTags.OFFSET" { Integer }
223226
"$InstrumentationTags.CONSUMER_GROUP" "sender"
224227
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG)
228+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
225229
"$InstrumentationTags.RECORD_QUEUE_TIME_MS" { it >= 0 }
226230
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$KafkaClientTestBase.SHARED_TOPIC"
227231
defaultTags(true)

dd-java-agent/instrumentation/kafka/kafka-clients-3.8/src/test/groovy/KafkaClientTestBase.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -914,9 +914,9 @@ abstract class KafkaClientTestBase extends VersionedNamingTestBase {
914914
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
915915
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)
916916
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$SHARED_TOPIC"
917-
if (partitioned) {
918-
"$InstrumentationTags.PARTITION" { it >= 0 }
919-
}
917+
"$InstrumentationTags.PARTITION" { it >= 0 }
918+
"$InstrumentationTags.OFFSET" { it >= 0 }
919+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
920920
if (tombstone) {
921921
"$InstrumentationTags.TOMBSTONE" true
922922
}
@@ -993,6 +993,7 @@ abstract class KafkaClientTestBase extends VersionedNamingTestBase {
993993
"$InstrumentationTags.OFFSET" { offset.containsWithinBounds(it as int) }
994994
"$InstrumentationTags.CONSUMER_GROUP" "sender"
995995
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG)
996+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
996997
"$InstrumentationTags.RECORD_QUEUE_TIME_MS" { it >= 0 }
997998
"$InstrumentationTags.RECORD_END_TO_END_DURATION_MS" { it >= 0 }
998999
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$SHARED_TOPIC"

dd-java-agent/instrumentation/kafka/kafka-streams-0.11/src/latestDepTest/groovy/KafkaStreamsTest.groovy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ class KafkaStreamsTest extends InstrumentationSpecification {
132132
"$Tags.COMPONENT" "java-kafka"
133133
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
134134
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$STREAM_PENDING"
135+
"$InstrumentationTags.PARTITION" { it >= 0 }
136+
"$InstrumentationTags.OFFSET" { it >= 0 }
137+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
135138
if ({ isDataStreamsEnabled()}) {
136139
"$DDTags.PATHWAY_HASH" { String }
137140
}
@@ -183,6 +186,9 @@ class KafkaStreamsTest extends InstrumentationSpecification {
183186
"$Tags.COMPONENT" "java-kafka"
184187
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
185188
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$STREAM_PROCESSED"
189+
"$InstrumentationTags.PARTITION" { it >= 0 }
190+
"$InstrumentationTags.OFFSET" { it >= 0 }
191+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
186192
if ({ isDataStreamsEnabled()}) {
187193
"$DDTags.PATHWAY_HASH" { String }
188194
}
@@ -206,6 +212,7 @@ class KafkaStreamsTest extends InstrumentationSpecification {
206212
"$InstrumentationTags.PARTITION" { it >= 0 }
207213
"$InstrumentationTags.OFFSET" 0
208214
"$InstrumentationTags.CONSUMER_GROUP" "sender"
215+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
209216
"$InstrumentationTags.RECORD_QUEUE_TIME_MS" { it >= 0 }
210217
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$STREAM_PROCESSED"
211218
"testing" 123

dd-java-agent/instrumentation/kafka/kafka-streams-0.11/src/test/groovy/KafkaStreamsTestBase.groovy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ abstract class KafkaStreamsTestBase extends VersionedNamingTestBase {
158158
"$Tags.COMPONENT" "java-kafka"
159159
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
160160
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$STREAM_PENDING"
161+
"$InstrumentationTags.PARTITION" { it >= 0 }
162+
"$InstrumentationTags.OFFSET" { it >= 0 }
163+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
161164
if ({ isDataStreamsEnabled() }){
162165
"$DDTags.PATHWAY_HASH" { String }
163166
}
@@ -226,6 +229,9 @@ abstract class KafkaStreamsTestBase extends VersionedNamingTestBase {
226229
"$Tags.COMPONENT" "java-kafka"
227230
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
228231
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$STREAM_PROCESSED"
232+
"$InstrumentationTags.PARTITION" { it >= 0 }
233+
"$InstrumentationTags.OFFSET" { it >= 0 }
234+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
229235
if ({isDataStreamsEnabled()}) {
230236
"$DDTags.PATHWAY_HASH" { String }
231237
}
@@ -269,6 +275,7 @@ abstract class KafkaStreamsTestBase extends VersionedNamingTestBase {
269275
"$InstrumentationTags.PARTITION" { it >= 0 }
270276
"$InstrumentationTags.OFFSET" 0
271277
"$InstrumentationTags.CONSUMER_GROUP" "sender"
278+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
272279
"$InstrumentationTags.RECORD_QUEUE_TIME_MS" { it >= 0 }
273280
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$STREAM_PROCESSED"
274281
"testing" 123

dd-java-agent/instrumentation/spring/spring-messaging-4.0/src/test/groovy/KafkaBatchListenerCoroutineTest.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ class KafkaBatchListenerCoroutineTest extends InstrumentationSpecification {
114114
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
115115
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" TOPIC
116116
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" { String }
117+
"$InstrumentationTags.PARTITION" { it >= 0 }
118+
"$InstrumentationTags.OFFSET" { it >= 0 }
119+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
117120
peerServiceFrom(InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS)
118121
defaultTags()
119122
}
@@ -133,6 +136,7 @@ class KafkaBatchListenerCoroutineTest extends InstrumentationSpecification {
133136
"$Tags.SPAN_KIND" Tags.SPAN_KIND_CONSUMER
134137
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" TOPIC
135138
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" { String }
139+
"$InstrumentationTags.KAFKA_CLUSTER_ID" { String }
136140
peerServiceFrom(InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS)
137141
"$InstrumentationTags.CONSUMER_GROUP" CONSUMER_GROUP
138142
"$InstrumentationTags.OFFSET" offset

0 commit comments

Comments
 (0)