Skip to content

Commit 8376fe4

Browse files
authored
Added missing messaging semantic attributes on the consumer spans (#856)
* Added missing messaging semantic attributes on the consumer spans Signed-off-by: Paolo Patierno <[email protected]> * Lower casing the consumer span operation name Signed-off-by: Paolo Patierno <[email protected]> --------- Signed-off-by: Paolo Patierno <[email protected]>
1 parent 2f56885 commit 8376fe4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 0.28.0
44

55
* Dependency updates (Kafka 3.6.1, Kubernetes configuration provider 1.1.2, Vert.x 4.5.0)
6+
* Fixed missing messaging semantic attributes to the Kafka consumer spans
67

78
## 0.27.0
89

src/main/java/io/strimzi/kafka/bridge/tracing/OpenTelemetryHandle.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.kafka.clients.producer.ProducerRecord;
2929

3030
import java.nio.charset.StandardCharsets;
31+
import java.util.Locale;
3132
import java.util.Map;
3233
import java.util.Properties;
3334

@@ -90,8 +91,11 @@ private SpanBuilder getSpanBuilder(RoutingContext routingContext, String operati
9091

9192
@Override
9293
public <K, V> void handleRecordSpan(ConsumerRecord<K, V> record) {
93-
String operationName = record.topic() + " " + MessageOperation.RECEIVE;
94+
String operationName = record.topic() + " " + MessageOperation.RECEIVE.name().toLowerCase(Locale.ROOT);
9495
SpanBuilder spanBuilder = get().spanBuilder(operationName);
96+
spanBuilder.setAttribute(SemanticAttributes.MESSAGING_DESTINATION, record.topic());
97+
spanBuilder.setAttribute(SemanticAttributes.MESSAGING_DESTINATION_KIND, SemanticAttributes.MessagingDestinationKindValues.TOPIC);
98+
spanBuilder.setAttribute(SemanticAttributes.MESSAGING_SYSTEM, "kafka");
9599
Context parentContext = propagator().extract(Context.current(), TracingUtil.toHeaders(record), MG);
96100
if (parentContext != null) {
97101
Span parentSpan = Span.fromContext(parentContext);

0 commit comments

Comments
 (0)