-
Notifications
You must be signed in to change notification settings - Fork 910
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change Async Servlet span end logic to fix race condition on Undertow (…
…#2992) * Attach servlet async listener with asyncStart instrumentation * Exclude Spring packages containing servlet request classes from global ignores * Exclude Tapestry HSR proxy with global ignore * Improve comments. * Fix for Liberty - request response when adding async listener * Removed unused methods * Explicit response to async listeners on all servlet engines * Attach response to request on Jetty * Fix broken build due to rebase, improved a comment * Address PR comments * Added a comment. * Addressed PR comments
- Loading branch information
1 parent
5f373b3
commit fd132d4
Showing
33 changed files
with
403 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ava/io/opentelemetry/javaagent/instrumentation/servlet/v3_0/Servlet3AsyncStartAdvice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.servlet.v3_0; | ||
|
||
import static io.opentelemetry.instrumentation.servlet.v3_0.Servlet3HttpServerTracer.tracer; | ||
|
||
import io.opentelemetry.javaagent.instrumentation.api.CallDepthThreadLocalMap; | ||
import javax.servlet.AsyncContext; | ||
import javax.servlet.ServletRequest; | ||
import javax.servlet.http.HttpServletRequest; | ||
import net.bytebuddy.asm.Advice; | ||
|
||
public class Servlet3AsyncStartAdvice { | ||
@Advice.OnMethodEnter(suppress = Throwable.class) | ||
public static void startAsyncEnter() { | ||
// This allows to detect the outermost invocation of startAsync in method exit | ||
CallDepthThreadLocalMap.incrementCallDepth(AsyncContext.class); | ||
} | ||
|
||
@Advice.OnMethodExit(suppress = Throwable.class) | ||
public static void startAsyncExit(@Advice.This ServletRequest servletRequest) { | ||
int callDepth = CallDepthThreadLocalMap.decrementCallDepth(AsyncContext.class); | ||
|
||
if (callDepth != 0) { | ||
// This is not the outermost invocation, ignore. | ||
return; | ||
} | ||
|
||
if (servletRequest instanceof HttpServletRequest) { | ||
HttpServletRequest request = (HttpServletRequest) servletRequest; | ||
|
||
if (!tracer().isAsyncListenerAttached(request)) { | ||
tracer().attachAsyncListener(request); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
...java/io/opentelemetry/javaagent/instrumentation/servlet/v3_0/TagSettingAsyncListener.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.