Skip to content

Commit

Permalink
Fix test case
Browse files Browse the repository at this point in the history
Signed-off-by: Gagan Juneja <[email protected]>
  • Loading branch information
Gagan Juneja committed Sep 8, 2023
1 parent 89d5413 commit 0aacc18
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private static String createSpanName(String action, Transport.Connection connect
private static Attributes buildSpanAttributes(String action, Transport.Connection connection) {
Attributes attributes = Attributes.create().addAttribute(AttributeNames.TRANSPORT_ACTION, action);
if (connection != null && connection.getNode() != null) {
attributes.addAttribute(AttributeNames.TRANSPORT_TARGET_HOST, connection.getNode().getHostAddress());
attributes.addAttribute(AttributeNames.TRANSPORT_TARGET_HOST, connection.getNode().getHostAddress() + connection.getNode().getName() + connection.getNode().getId() + connection.getNode().getHostName());
}
return attributes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.opensearch.telemetry.tracing.TracingTelemetry;
import org.opensearch.telemetry.tracing.attributes.Attributes;

import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

/**
Expand All @@ -36,7 +37,7 @@ public MockTracingTelemetry() {}
public Span createSpan(String spanName, Span parentSpan, Attributes attributes) {
Span span = new MockSpan(spanName, parentSpan, spanProcessor, attributes);
if (shutdown.get() == false) {
logger.info("adding span {} {}", Thread.currentThread().getName(), span);
logger.info("adding span {} {}", Thread.currentThread().getName(), toMockSpanData(span));
spanProcessor.onStart(span);
}
return span;
Expand All @@ -54,4 +55,19 @@ public void close() {
shutdown.set(true);
}

private MockSpanData toMockSpanData(Span span) {
String parentSpanId = (span.getParentSpan() != null) ? span.getParentSpan().getSpanId() : "";
MockSpanData spanData = new MockSpanData(
span.getSpanId(),
parentSpanId,
span.getTraceId(),
System.nanoTime(),
false,
span.getSpanName(),
Thread.currentThread().getStackTrace(),
(span instanceof MockSpan) ? ((MockSpan) span).getAttributes() : Map.of()
);
return spanData;
}

}

0 comments on commit 0aacc18

Please sign in to comment.