Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;

/**
Expand All @@ -44,6 +45,7 @@ public CallbackAdapterInterceptor(CallbackCache callbackCache) {
public void onCompletion(RecordMetadata metadata, Exception exception) {
ContextSnapshot snapshot = callbackCache.getSnapshot();
AbstractSpan activeSpan = ContextManager.createLocalSpan("Kafka/Producer/Callback");
SpanLayer.asMQ(activeSpan);
activeSpan.setComponent(ComponentsDefine.KAFKA_PRODUCER);
if (metadata != null) {
Tags.MQ_TOPIC.set(activeSpan, metadata.topic());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
Expand All @@ -43,6 +44,7 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr
ContextSnapshot snapshot = getSnapshot(cache);
RecordMetadata metadata = (RecordMetadata) allArguments[0];
AbstractSpan activeSpan = ContextManager.createLocalSpan("Kafka/Producer/Callback");
SpanLayer.asMQ(activeSpan);
activeSpan.setComponent(ComponentsDefine.KAFKA_PRODUCER);
if (metadata != null) {
// Null if an error occurred during processing of this record
Expand Down
4 changes: 2 additions & 2 deletions test/plugin/scenarios/kafka-scenario/config/expectedData.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ segmentItems:
operationId: 0
parentSpanId: -1
spanId: 0
spanLayer: Unknown
spanLayer: MQ
startTime: nq 0
endTime: nq 0
componentId: 40
Expand All @@ -43,7 +43,7 @@ segmentItems:
operationId: 0
parentSpanId: -1
spanId: 0
spanLayer: Unknown
spanLayer: MQ
startTime: nq 0
endTime: nq 0
componentId: 40
Expand Down