@@ -25,7 +25,8 @@ import io.netty.handler.codec.http.{HttpRequest, HttpResponse}
2525import io .netty .util .concurrent .GenericFutureListener
2626import kamon .{ClassLoading , Kamon }
2727import kamon .context .Storage
28- import kamon .instrumentation .akka .http .ServerFlowWrapper
28+ import kamon .instrumentation .akka .http .{ServerFlowWrapper => AkkaHttpServerFlowWrapper }
29+ import kamon .instrumentation .pekko .http .{ServerFlowWrapper => PekkoHttpServerFlowWrapper }
2930import kamon .instrumentation .context .{CaptureCurrentTimestampOnExit , HasTimestamp }
3031import kamon .instrumentation .http .HttpServerInstrumentation .RequestHandler
3132import kamon .instrumentation .http .{HttpMessage , HttpServerInstrumentation }
@@ -52,7 +53,18 @@ class PlayServerInstrumentation extends InstrumentationBuilder {
5253 .when(classIsPresent(" play.core.server.AkkaHttpServerProvider" ))
5354 .advise(
5455 anyMethods(" createServerBinding" , " play$core$server$AkkaHttpServer$$createServerBinding" ),
55- CreateServerBindingAdvice
56+ CreateAkkaHttpServerBindingAdvice
57+ )
58+
59+ /**
60+ * When using the Pekko HTTP server, we will use the exact same instrumentation that comes from the Pekko HTTP module,
61+ * the only difference here is that we will change the component name.
62+ */
63+ onType(" play.core.server.PekkoHttpServer" )
64+ .when(classIsPresent(" play.core.server.PekkoHttpServerProvider" ))
65+ .advise(
66+ anyMethods(" createServerBinding" , " play$core$server$PekkoHttpServer$$createServerBinding" ),
67+ CreatePekkoHttpServerBindingAdvice
5668 )
5769
5870 /**
@@ -87,15 +99,27 @@ class PlayServerInstrumentation extends InstrumentationBuilder {
8799
88100}
89101
90- object CreateServerBindingAdvice {
102+ object CreateAkkaHttpServerBindingAdvice {
103+
104+ @ Advice .OnMethodEnter
105+ def enter (): Unit =
106+ AkkaHttpServerFlowWrapper .changeSettings(" play.server.akka-http" , " kamon.instrumentation.play.http.server" )
107+
108+ @ Advice .OnMethodExit
109+ def exit (): Unit =
110+ AkkaHttpServerFlowWrapper .resetSettings()
111+
112+ }
113+
114+ object CreatePekkoHttpServerBindingAdvice {
91115
92116 @ Advice .OnMethodEnter
93117 def enter (): Unit =
94- ServerFlowWrapper .changeSettings(" play.server.akka -http" , " kamon.instrumentation.play.http.server" )
118+ PekkoHttpServerFlowWrapper .changeSettings(" play.server.pekko -http" , " kamon.instrumentation.play.http.server" )
95119
96120 @ Advice .OnMethodExit
97121 def exit (): Unit =
98- ServerFlowWrapper .resetSettings()
122+ PekkoHttpServerFlowWrapper .resetSettings()
99123
100124}
101125
0 commit comments