From 7c67ce77de6581096453babd4f03a59aa43dd01b Mon Sep 17 00:00:00 2001 From: Serge Zaitsev Date: Fri, 31 Jan 2020 09:12:44 +0100 Subject: [PATCH] use "message_bus.destination" tag for both, producer and consumer (#71) --- .../io/opentracing/contrib/kafka/StandardSpanDecorator.java | 2 +- .../java/io/opentracing/contrib/kafka/TracingKafkaTest.java | 4 ++-- .../contrib/kafka/streams/TracingKafkaStreamsTest.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/opentracing-kafka-client/src/main/java/io/opentracing/contrib/kafka/StandardSpanDecorator.java b/opentracing-kafka-client/src/main/java/io/opentracing/contrib/kafka/StandardSpanDecorator.java index 6d226de..399a1c8 100644 --- a/opentracing-kafka-client/src/main/java/io/opentracing/contrib/kafka/StandardSpanDecorator.java +++ b/opentracing-kafka-client/src/main/java/io/opentracing/contrib/kafka/StandardSpanDecorator.java @@ -37,8 +37,8 @@ public void onSend(ProducerRecord record, Span span) { public void onResponse(ConsumerRecord record, Span span) { setCommonTags(span); + Tags.MESSAGE_BUS_DESTINATION.set(span, record.topic()); span.setTag("partition", record.partition()); - span.setTag("topic", record.topic()); span.setTag("offset", record.offset()); } diff --git a/opentracing-kafka-client/src/test/java/io/opentracing/contrib/kafka/TracingKafkaTest.java b/opentracing-kafka-client/src/test/java/io/opentracing/contrib/kafka/TracingKafkaTest.java index 46f6354..5bb11b1 100644 --- a/opentracing-kafka-client/src/test/java/io/opentracing/contrib/kafka/TracingKafkaTest.java +++ b/opentracing-kafka-client/src/test/java/io/opentracing/contrib/kafka/TracingKafkaTest.java @@ -728,7 +728,7 @@ private void checkSpans(List mockSpans) { assertEquals(0, mockSpan.tags().get("partition")); long offset = (Long) mockSpan.tags().get("offset"); assertTrue(offset >= 0L); - assertEquals("messages", mockSpan.tags().get("topic")); + assertEquals("messages", mockSpan.tags().get(Tags.MESSAGE_BUS_DESTINATION.getKey())); } assertEquals(StandardSpanDecorator.COMPONENT_NAME, mockSpan.tags().get(Tags.COMPONENT.getKey())); @@ -764,4 +764,4 @@ private List getByOperationNameAll(List spans, String operat return found; } -} \ No newline at end of file +} diff --git a/opentracing-kafka-streams/src/test/java/io/opentracing/contrib/kafka/streams/TracingKafkaStreamsTest.java b/opentracing-kafka-streams/src/test/java/io/opentracing/contrib/kafka/streams/TracingKafkaStreamsTest.java index 625b553..746eb6b 100644 --- a/opentracing-kafka-streams/src/test/java/io/opentracing/contrib/kafka/streams/TracingKafkaStreamsTest.java +++ b/opentracing-kafka-streams/src/test/java/io/opentracing/contrib/kafka/streams/TracingKafkaStreamsTest.java @@ -117,7 +117,7 @@ private void checkSpans(List mockSpans) { assertEquals(0, mockSpan.tags().get("partition")); long offset = (Long) mockSpan.tags().get("offset"); assertTrue(offset == 0L || offset == 1L || offset == 2L); - String topicName = (String) mockSpan.tags().get("topic"); + String topicName = (String) mockSpan.tags().get(Tags.MESSAGE_BUS_DESTINATION.getKey()); assertTrue(topicName.equals("stream-out") || topicName.equals("stream-test")); } assertEquals("java-kafka", mockSpan.tags().get(Tags.COMPONENT.getKey())); @@ -132,4 +132,4 @@ private void checkSpans(List mockSpans) { private Callable reportedSpansSize() { return () -> mockTracer.finishedSpans().size(); } -} \ No newline at end of file +}