Skip to content

Commit

Permalink
Added missing messaging semantic attributes on the consumer spans (#856)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
ppatierno authored Dec 20, 2023
1 parent 2f56885 commit 8376fe4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 0.28.0

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

## 0.27.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.kafka.clients.producer.ProducerRecord;

import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;

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

@Override
public <K, V> void handleRecordSpan(ConsumerRecord<K, V> record) {
String operationName = record.topic() + " " + MessageOperation.RECEIVE;
String operationName = record.topic() + " " + MessageOperation.RECEIVE.name().toLowerCase(Locale.ROOT);
SpanBuilder spanBuilder = get().spanBuilder(operationName);
spanBuilder.setAttribute(SemanticAttributes.MESSAGING_DESTINATION, record.topic());
spanBuilder.setAttribute(SemanticAttributes.MESSAGING_DESTINATION_KIND, SemanticAttributes.MessagingDestinationKindValues.TOPIC);
spanBuilder.setAttribute(SemanticAttributes.MESSAGING_SYSTEM, "kafka");
Context parentContext = propagator().extract(Context.current(), TracingUtil.toHeaders(record), MG);
if (parentContext != null) {
Span parentSpan = Span.fromContext(parentContext);
Expand Down

0 comments on commit 8376fe4

Please sign in to comment.