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 e7cf6ba commit eb99f2e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ public void onRejection(Exception e) {
@Override
public void onFailure(Exception e) {
logger.error("Failing from onFailure ", e);
contextToNotify.handler().handleRejection(e);
logger.warn(
() -> new ParameterizedMessage(
"failed to notify response handler on exception, action: {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
import org.opensearch.telemetry.tracing.TracingTelemetry;
import org.opensearch.telemetry.tracing.attributes.Attributes;

import java.util.concurrent.atomic.AtomicBoolean;

/**
* Mock {@link TracingTelemetry} implementation for testing.
*/
public class MockTracingTelemetry implements TracingTelemetry {

private final SpanProcessor spanProcessor = new StrictCheckSpanProcessor();
private final AtomicBoolean shutdown = new AtomicBoolean();

/**
* Base constructor.
Expand All @@ -28,7 +31,9 @@ public MockTracingTelemetry() {}
@Override
public Span createSpan(String spanName, Span parentSpan, Attributes attributes) {
Span span = new MockSpan(spanName, parentSpan, spanProcessor, attributes);
spanProcessor.onStart(span);
if (shutdown.get() == false) {
spanProcessor.onStart(span);
}
return span;
}

Expand All @@ -39,7 +44,8 @@ public TracingContextPropagator getContextPropagator() {

@Override
public void close() {
StrictCheckSpanProcessor.shutdown();
// StrictCheckSpanProcessor.shutdown();
shutdown.set(true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public StrictCheckSpanProcessor() {
}

private void initProcessor() {
restartTheProcessor();
// restartTheProcessor();
}

private static Map<String, MockSpanData> spanMap = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -81,7 +81,7 @@ private MockSpanData toMockSpanData(Span span) {
*/
public static synchronized void shutdown() {
if (shutdown.get() == false) {
shutdown.set(true);
// shutdown.set(true);
}
}

Expand Down Expand Up @@ -109,7 +109,7 @@ public static void validateTracingStateOnShutdown() {
spanMap.clear();
throw e;
} finally {
restartTheProcessor();
// restartTheProcessor();
}
}

Expand Down

0 comments on commit eb99f2e

Please sign in to comment.