diff --git a/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyBlockingHelper.java b/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyBlockingHelper.java index a6c2dd0dd71..0be7ae6ee01 100644 --- a/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyBlockingHelper.java +++ b/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyBlockingHelper.java @@ -5,7 +5,6 @@ import datadog.appsec.api.blocking.BlockingContentType; import datadog.trace.api.gateway.Flow; import datadog.trace.bootstrap.blocking.BlockingActionHelper; -import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentSpan; import java.io.OutputStream; import java.lang.invoke.MethodHandle; @@ -36,14 +35,14 @@ public class GrizzlyBlockingHelper { private GrizzlyBlockingHelper() {} public static boolean block( - Request request, Response response, Flow.Action.RequestBlockingAction rba, AgentScope scope) { + Request request, Response response, Flow.Action.RequestBlockingAction rba, AgentSpan span) { return block( request, response, rba.getStatusCode(), rba.getBlockingContentType(), rba.getExtraHeaders(), - scope); + span); } public static boolean block( @@ -52,7 +51,7 @@ public static boolean block( int statusCode, BlockingContentType bct, Map extraHeaders, - AgentScope scope) { + AgentSpan span) { if (GET_OUTPUT_STREAM == null) { return false; } @@ -77,15 +76,13 @@ public static boolean block( os.close(); response.finish(); - scope.span().getRequestContext().getTraceSegment().effectivelyBlocked(); + span.getRequestContext().getTraceSegment().effectivelyBlocked(); SpanClosingListener.LISTENER.onAfterService(request); } catch (Throwable e) { log.info("Error committing blocking response", e); - final AgentSpan span = scope.span(); DECORATE.onError(span, e); DECORATE.beforeFinish(span); span.finish(); - scope.close(); } return true; diff --git a/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyDecorator.java b/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyDecorator.java index ecc3f5bd223..3b3e5118565 100644 --- a/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyDecorator.java +++ b/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyDecorator.java @@ -4,7 +4,7 @@ import datadog.trace.api.gateway.BlockResponseFunction; import datadog.trace.api.internal.TraceSegment; import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; -import datadog.trace.bootstrap.instrumentation.api.AgentScope; +import datadog.trace.bootstrap.instrumentation.api.AgentSpan; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter; import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; @@ -90,9 +90,9 @@ public boolean tryCommitBlockingResponse( int statusCode, BlockingContentType templateType, Map extraHeaders) { - AgentScope agentScope = AgentTracer.get().activeScope(); - if (agentScope == null) { - log.warn("Can't block: no active scope"); + AgentSpan agentSpan = AgentTracer.get().activeSpan(); + if (agentSpan == null) { + log.warn("Can't block: no active span"); return false; } @@ -102,7 +102,7 @@ public boolean tryCommitBlockingResponse( statusCode, templateType, extraHeaders, - agentScope); + agentSpan); } } } diff --git a/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyHttpHandlerInstrumentation.java b/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyHttpHandlerInstrumentation.java index 881eb772f4c..2755a658781 100644 --- a/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyHttpHandlerInstrumentation.java +++ b/dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyHttpHandlerInstrumentation.java @@ -87,7 +87,7 @@ public static class HandleAdvice { Flow.Action.RequestBlockingAction rba = span.getRequestBlockingAction(); if (rba != null) { - boolean success = GrizzlyBlockingHelper.block(request, response, rba, scope); + boolean success = GrizzlyBlockingHelper.block(request, response, rba, span); if (success) { return true; /* skip body */ } diff --git a/dd-java-agent/instrumentation/grizzly-http-2.3.20/src/main/java/datadog/trace/instrumentation/grizzlyhttp232/FilterAdvice.java b/dd-java-agent/instrumentation/grizzly-http-2.3.20/src/main/java/datadog/trace/instrumentation/grizzlyhttp232/FilterAdvice.java index dd0056379ad..5fefa67984e 100644 --- a/dd-java-agent/instrumentation/grizzly-http-2.3.20/src/main/java/datadog/trace/instrumentation/grizzlyhttp232/FilterAdvice.java +++ b/dd-java-agent/instrumentation/grizzly-http-2.3.20/src/main/java/datadog/trace/instrumentation/grizzlyhttp232/FilterAdvice.java @@ -1,7 +1,7 @@ package datadog.trace.instrumentation.grizzlyhttp232; import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan; -import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope; +import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan; import static datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator.DD_SPAN_ATTRIBUTE; import datadog.trace.bootstrap.instrumentation.api.AgentScope; @@ -15,7 +15,7 @@ public class FilterAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) public static AgentScope onEnter( @Advice.This BaseFilter it, @Advice.Argument(0) final FilterChainContext ctx) { - if (ctx.getAttributes().getAttribute(DD_SPAN_ATTRIBUTE) == null || activeScope() != null) { + if (ctx.getAttributes().getAttribute(DD_SPAN_ATTRIBUTE) == null || activeSpan() != null) { return null; } AgentScope scope =