-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix akka-http instrumentation for HTTP2
- Loading branch information
Showing
5 changed files
with
52 additions
and
77 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...on-akka-http/src/main/java/kamon/instrumentation/akka/http/Http2BlueprintAsyncAdvice.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,35 @@ | ||
package kamon.instrumentation.akka.http; | ||
|
||
import akka.NotUsed; | ||
import akka.http.scaladsl.model.HttpRequest; | ||
import akka.http.scaladsl.model.HttpResponse; | ||
import akka.stream.scaladsl.Flow; | ||
import kanela.agent.libs.net.bytebuddy.asm.Advice; | ||
|
||
public class Http2BlueprintAsyncAdvice { | ||
|
||
public static class EndpointInfo { | ||
public final String listenInterface; | ||
public final int listenPort; | ||
|
||
public EndpointInfo(String listenInterface, int listenPort) { | ||
this.listenInterface = listenInterface; | ||
this.listenPort = listenPort; | ||
} | ||
} | ||
|
||
public static ThreadLocal<EndpointInfo> currentEndpoint = new ThreadLocal<>(); | ||
|
||
@Advice.OnMethodExit | ||
public static void onExit(@Advice.Return(readOnly = false) Flow<HttpRequest, HttpResponse, NotUsed> returnedFlow) { | ||
EndpointInfo bindAndHandlerEndpoint = currentEndpoint.get(); | ||
|
||
if(bindAndHandlerEndpoint != null) { | ||
returnedFlow = ServerFlowWrapper.apply( | ||
returnedFlow, | ||
bindAndHandlerEndpoint.listenInterface, | ||
bindAndHandlerEndpoint.listenPort | ||
); | ||
} | ||
} | ||
} |
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