Skip to content

Commit b9152d6

Browse files
committed
Review feedback
1 parent a544bec commit b9152d6

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/AiOperationNameSpanProcessor.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,13 @@ public class AiOperationNameSpanProcessor implements SpanProcessor {
3636

3737
@Override
3838
public void onStart(Context parentContext, ReadWriteSpan span) {
39-
Span serverSpan = ServerSpan.fromContextOrNull(parentContext);
40-
if (serverSpan instanceof ReadableSpan) {
39+
Span localRootSpan = ServerSpan.fromContextOrNull(parentContext);
40+
if (localRootSpan == null) {
41+
localRootSpan = ConsumerSpan.fromContextOrNull(parentContext);
42+
}
43+
if (localRootSpan instanceof ReadableSpan) {
4144
span.setAttribute(
42-
Exporter.AI_OPERATION_NAME_KEY, getOperationName((ReadableSpan) serverSpan));
43-
} else if (serverSpan == null) {
44-
Span consumerSpan = ConsumerSpan.fromContextOrNull(parentContext);
45-
if (consumerSpan instanceof ReadableSpan) {
46-
span.setAttribute(
47-
Exporter.AI_OPERATION_NAME_KEY, getOperationName((ReadableSpan) consumerSpan));
48-
}
45+
Exporter.AI_OPERATION_NAME_KEY, getOperationName((ReadableSpan) localRootSpan));
4946
}
5047
}
5148

0 commit comments

Comments
 (0)