From 1d4060988b3750de422133e85ec6c4272a9fa695 Mon Sep 17 00:00:00 2001 From: Gagan Juneja Date: Mon, 25 Sep 2023 22:27:44 +0530 Subject: [PATCH] Address review comment Signed-off-by: Gagan Juneja --- .../telemetry/tracing/SpanContext.java | 15 --------------- .../telemetry/tracing/SpanCreationContext.java | 18 ------------------ .../telemetry/tracing/DefaultTracerTests.java | 5 +++-- 3 files changed, 3 insertions(+), 35 deletions(-) diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanContext.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanContext.java index 58b0c06e6b587..f9af611553aff 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanContext.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanContext.java @@ -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. @@ -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); - } } diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanCreationContext.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanCreationContext.java index dd33b07bb2c85..cbbcfe7a85d57 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanCreationContext.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanCreationContext.java @@ -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. * @@ -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); - } } diff --git a/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/DefaultTracerTests.java b/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/DefaultTracerTests.java index 4752d85a22676..0a717e993cb81 100644 --- a/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/DefaultTracerTests.java +++ b/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/DefaultTracerTests.java @@ -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 { @@ -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); @@ -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); }