Skip to content

Commit

Permalink
Address review comment
Browse files Browse the repository at this point in the history
Signed-off-by: Gagan Juneja <gjjuneja@amazon.com>
  • Loading branch information
Gagan Juneja committed Sep 25, 2023
1 parent 2412b78 commit 1d40609
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import org.opensearch.common.annotation.ExperimentalApi;

import java.util.Objects;

/**
* Wrapped Span will be exposed to the code outside of tracing package for sharing the {@link Span} without having access to
* its properties.
Expand All @@ -33,17 +31,4 @@ public SpanContext(Span span) {
Span getSpan() {
return span;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SpanContext)) return false;
SpanContext that = (SpanContext) o;
return Objects.equals(span, that.span);
}

@Override
public int hashCode() {
return Objects.hash(span);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import org.opensearch.common.annotation.ExperimentalApi;
import org.opensearch.telemetry.tracing.attributes.Attributes;

import java.util.Objects;

/**
* Context for span details.
*
Expand Down Expand Up @@ -121,20 +119,4 @@ public SpanKind getSpanKind() {
public SpanContext getParent() {
return parent;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SpanCreationContext)) return false;
SpanCreationContext that = (SpanCreationContext) o;
return spanName.equals(that.spanName)
&& attributes.equals(that.attributes)
&& spanKind == that.spanKind
&& parent.equals(that.parent);
}

@Override
public int hashCode() {
return Objects.hash(spanName, attributes, spanKind, parent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class DefaultTracerTests extends OpenSearchTestCase {
private SpanScope mockSpanScope;
private ThreadPool threadPool;
private ExecutorService executorService;
private SpanCreationContext spanCreationContext;

@Override
public void setUp() throws Exception {
Expand All @@ -57,7 +58,7 @@ public void tearDown() throws Exception {
public void testCreateSpan() {
DefaultTracer defaultTracer = new DefaultTracer(mockTracingTelemetry, mockTracerContextStorage);

defaultTracer.startSpan(buildSpanCreationContext("span_name", Attributes.EMPTY, mockParentSpan));
defaultTracer.startSpan(spanCreationContext);

String spanName = defaultTracer.getCurrentSpan().getSpan().getSpanName();
assertEquals("span_name", spanName);
Expand Down Expand Up @@ -409,8 +410,8 @@ private void setupMocks() {
when(mockSpan.getParentSpan()).thenReturn(mockParentSpan);
when(mockParentSpan.getSpanId()).thenReturn("parent_span_id");
when(mockParentSpan.getTraceId()).thenReturn("trace_id");
spanCreationContext = buildSpanCreationContext("span_name", Attributes.EMPTY, mockParentSpan);
when(mockTracerContextStorage.get(TracerContextStorage.CURRENT_SPAN)).thenReturn(mockSpan, mockParentSpan);
SpanCreationContext spanCreationContext = buildSpanCreationContext("span_name", Attributes.EMPTY, mockParentSpan);
when(mockTracingTelemetry.createSpan(eq(spanCreationContext), eq(mockParentSpan))).thenReturn(mockSpan);
}

Expand Down

0 comments on commit 1d40609

Please sign in to comment.