Skip to content

Commit

Permalink
Merge ab4d13a into d3f688d
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithasudhakar committed Oct 22, 2023
2 parents d3f688d + ab4d13a commit 97c99de
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

Expand Down Expand Up @@ -111,7 +112,17 @@ public Span addTraceInfoToSpan(ChannelHandlerContext ctx, CloudEvent cloudEvent)
}
Context context = ctx.channel().attr(AttributeKeys.SERVER_CONTEXT).get();
Span span = context != null ? context.get(SpanKey.SERVER_KEY) : null;
return addTraceInfoToSpan(span, cloudEvent);

if (span == null) {
log.warn("span is null when finishSpan");
return null;

Check warning on line 118 in eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/Trace.java

View check run for this annotation

Codecov / codecov/patch

eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/Trace.java#L117-L118

Added lines #L117 - L118 were not covered by tests
}

//add trace info
for (String entry : cloudEvent.getExtensionNames()) {
span.setAttribute(entry, cloudEvent.getExtension(entry) == null ? "" : Objects.requireNonNull(cloudEvent.getExtension(entry)).toString());
}
return span;

Check warning on line 125 in eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/Trace.java

View check run for this annotation

Codecov / codecov/patch

eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/Trace.java#L124-L125

Added lines #L124 - L125 were not covered by tests
}

public Span addTraceInfoToSpan(Span span, CloudEvent cloudEvent) {
Expand All @@ -130,7 +141,7 @@ public Span addTraceInfoToSpan(Span span, CloudEvent cloudEvent) {

// add trace info
for (String entry : cloudEvent.getExtensionNames()) {
span.setAttribute(entry, cloudEvent.getExtension(entry) == null ? "" : cloudEvent.getExtension(entry).toString());
span.setAttribute(entry, cloudEvent.getExtension(entry) != null ? cloudEvent.getExtension(entry).toString() : "");
}
return span;
}
Expand Down

0 comments on commit 97c99de

Please sign in to comment.