Skip to content

Commit

Permalink
pekko-grpc tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
hughsimpson committed Dec 1, 2023
1 parent eb3628c commit c0fbd9f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ lazy val `kamon-pekko-grpc` = (project in file("instrumentation/kamon-pekko-grpc
.settings(instrumentationSettings)
.settings(Seq(
PB.additionalDependencies := Seq.empty,
crossScalaVersions := Seq(`scala_2.12_version`, `scala_2.13_version`),
crossScalaVersions := Seq(`scala_2.12_version`, `scala_2.13_version`, scala_3_version),
libraryDependencies ++= Seq(
kanelaAgent % "provided",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import kamon.Kamon
import kanela.agent.api.instrumentation.InstrumentationBuilder
import kanela.agent.libs.net.bytebuddy.asm.Advice

import scala.annotation.static

class PekkoGrpcServerInstrumentation extends InstrumentationBuilder {

/**
Expand All @@ -33,18 +35,19 @@ class PekkoGrpcServerInstrumentation extends InstrumentationBuilder {
* otherwise the span remains unchanged. Assumes no actual implementation of `pekko.grpc.internal.TelemetrySpi` is
* configured.
*/
onType("org.apache.pekko.grpc.internal.NoOpTelemetry$")
.advise(method("onRequest"), PekkoGRPCServerRequestHandler)
onType("org.apache.pekko.grpc.internal.TelemetrySpi")
.advise(method("onRequest"), classOf[PekkoGRPCServerRequestHandler])


onType("org.apache.pekko.grpc.scaladsl.GrpcMarshalling")
.advise(method("unmarshal"), classOf[PekkoGRPCUnmarshallingContextPropagation])
}

class PekkoGRPCServerRequestHandler
object PekkoGRPCServerRequestHandler {

@Advice.OnMethodEnter()
def enter(@Advice.Argument(0) serviceName: String, @Advice.Argument(1) method: String): Unit = {
@static def enter(@Advice.Argument(0) serviceName: String, @Advice.Argument(1) method: String): Unit = {
val fullSpanName = serviceName + "/" + method
Kamon.currentSpan()
.name(fullSpanName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ import org.scalatest.concurrent.Eventually
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec

import scala.concurrent.ExecutionContextExecutor
import scala.concurrent.duration._

class PekkoGrpcTracingSpec extends AnyWordSpec with InitAndStopKamonAfterAll with Matchers with Eventually
with TestSpanReporter with OptionValues {

implicit val system = ActorSystem("pekko-grpc-instrumentation")
implicit val ec = system.dispatcher
implicit val system: ActorSystem = ActorSystem("pekko-grpc-instrumentation")
implicit val ec: ExecutionContextExecutor = system.dispatcher

val greeterService = GreeterServiceHandler(new GreeterServiceImpl())
val serverBinding = Http()
Expand All @@ -56,9 +57,4 @@ class PekkoGrpcTracingSpec extends AnyWordSpec with InitAndStopKamonAfterAll wit
}
}
}

override protected def beforeAll(): Unit = {
super.beforeAll()
enableFastSpanFlushing()
}
}

0 comments on commit c0fbd9f

Please sign in to comment.