File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
dd-java-agent/instrumentation/undertow/undertow-2.0/src/main/java/datadog/trace/instrumentation/undertow Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change 33import static datadog .trace .agent .tooling .bytebuddy .matcher .HierarchyMatchers .extendsClass ;
44import static datadog .trace .agent .tooling .bytebuddy .matcher .NameMatchers .named ;
55import static datadog .trace .bootstrap .instrumentation .api .AgentTracer .activateSpan ;
6- import static datadog .trace .bootstrap .instrumentation .api .AgentTracer .activeScope ;
6+ import static datadog .trace .bootstrap .instrumentation .api .AgentTracer .activeSpan ;
7+ import static datadog .trace .bootstrap .instrumentation .api .AgentTracer .closeActive ;
78import static datadog .trace .instrumentation .undertow .UndertowDecorator .DECORATE ;
89import static net .bytebuddy .matcher .ElementMatchers .isMethod ;
910import static net .bytebuddy .matcher .ElementMatchers .takesArgument ;
@@ -71,12 +72,10 @@ public static void afterRequestParse(
7172 // a span
7273 // this because undertow will just write down a http 400 raw response over the net channel.
7374 // Here we try to create a span to record this
74- AgentScope scope = activeScope ();
75- AgentSpan span = null ;
75+ AgentSpan span = activeSpan ();
76+ AgentScope scope = null ;
7677 try {
77- if (scope != null ) {
78- span = scope .span ();
79- } else {
78+ if (span == null ) {
8079 final AgentSpanContext .Extracted extractedContext = DECORATE .extract (exchange );
8180 span = DECORATE .startSpan (exchange , extractedContext ).setMeasured (true );
8281 scope = activateSpan (span );
@@ -90,9 +89,11 @@ public static void afterRequestParse(
9089 } finally {
9190 if (span != null ) {
9291 span .finish ();
93- }
94- if (scope != null ) {
95- scope .close ();
92+ if (scope != null ) {
93+ scope .close ();
94+ } else {
95+ closeActive ();
96+ }
9697 }
9798 }
9899 }
You can’t perform that action at this time.
0 commit comments