Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing messaging semantic attributes on the consumer spans #856

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the motivation behind using Locale.ROOT? I do not think we use it in many other places.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the way the official interceptor applies the lowecase, I was just applying the same.

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