11package datadog .trace .instrumentation .grizzly ;
22
33import static datadog .trace .agent .tooling .bytebuddy .matcher .NameMatchers .named ;
4- import static datadog .trace .bootstrap .instrumentation .api .AgentTracer .activateSpan ;
54import static datadog .trace .bootstrap .instrumentation .decorator .HttpServerDecorator .DD_SPAN_ATTRIBUTE ;
65import static datadog .trace .instrumentation .grizzly .GrizzlyDecorator .DECORATE ;
76import static net .bytebuddy .matcher .ElementMatchers .isMethod ;
87import static net .bytebuddy .matcher .ElementMatchers .takesArgument ;
98
109import com .google .auto .service .AutoService ;
10+ import datadog .context .Context ;
11+ import datadog .context .ContextScope ;
1112import datadog .trace .agent .tooling .Instrumenter ;
1213import datadog .trace .agent .tooling .InstrumenterModule ;
1314import datadog .trace .api .CorrelationIdentifier ;
1415import datadog .trace .api .GlobalTracer ;
1516import datadog .trace .api .gateway .Flow ;
16- import datadog .trace .bootstrap .instrumentation .api .AgentScope ;
1717import datadog .trace .bootstrap .instrumentation .api .AgentSpan ;
18- import datadog .trace .bootstrap .instrumentation .api .AgentSpanContext ;
1918import net .bytebuddy .asm .Advice ;
2019import org .glassfish .grizzly .http .server .Request ;
2120import org .glassfish .grizzly .http .server .Response ;
@@ -66,19 +65,19 @@ public static class HandleAdvice {
6665
6766 @ Advice .OnMethodEnter (suppress = Throwable .class , skipOn = Advice .OnNonDefaultValue .class )
6867 public static boolean /* skip body */ methodEnter (
69- @ Advice .Local ("agentScope " ) AgentScope scope ,
68+ @ Advice .Local ("contextScope " ) ContextScope scope ,
7069 @ Advice .Argument (0 ) final Request request ,
7170 @ Advice .Argument (1 ) final Response response ) {
7271 if (request .getAttribute (DD_SPAN_ATTRIBUTE ) != null ) {
7372 return false ;
7473 }
7574
76- final AgentSpanContext . Extracted parentContext = DECORATE .extract (request );
77- final AgentSpan span = DECORATE .startSpan (request , parentContext );
75+ final Context context = DECORATE .extractContext (request );
76+ final AgentSpan span = DECORATE .startSpan (request , DECORATE . getExtractedSpanContext ( context ) );
7877 DECORATE .afterStart (span );
79- DECORATE .onRequest (span , request , request , parentContext );
78+ DECORATE .onRequest (span , request , request , DECORATE . getExtractedSpanContext ( context ) );
8079
81- scope = activateSpan ( span );
80+ scope = DECORATE . activateScope ( context , span );
8281
8382 request .setAttribute (DD_SPAN_ATTRIBUTE , span );
8483 request .setAttribute (CorrelationIdentifier .getTraceIdKey (), GlobalTracer .get ().getTraceId ());
@@ -101,14 +100,15 @@ public static class HandleAdvice {
101100 public static void methodExit (
102101 @ Advice .Enter boolean skippedBody ,
103102 @ Advice .Return (readOnly = false ) boolean retVal ,
104- @ Advice .Local ("agentScope " ) AgentScope scope ,
103+ @ Advice .Local ("contextScope " ) ContextScope scope ,
105104 @ Advice .Thrown final Throwable throwable ) {
106105 if (scope == null ) {
107106 return ;
108107 }
109108
110109 if (throwable != null ) {
111- final AgentSpan span = scope .span ();
110+ final Context context = scope .context ();
111+ final AgentSpan span = AgentSpan .fromContext (context );
112112 DECORATE .onError (span , throwable );
113113 DECORATE .beforeFinish (span );
114114 span .finish ();
0 commit comments