From 073c05cb22c8e6d97255f2ff63005847285c2665 Mon Sep 17 00:00:00 2001 From: Ivan Topolnjak Date: Sat, 16 Nov 2019 16:30:25 +0100 Subject: [PATCH] upgrade to Akka 2.6, fixes #62, fixes #58 --- .../akka/ActorCreationBench.scala | 0 build.sbt | 121 +- .../akka/remote}/ContextAwareWireFormats.java | 314 +- .../protobuf/ContextAwareWireFormats.proto | 2 +- .../src/main/protobuf/WireFormats.proto | 0 .../akka_26/DispatcherInstrumentation.scala | 22 + .../remote/RemotingInstrumentation.scala | 6 + .../akka_25}/DispatcherInstrumentation.scala | 69 +- .../remote/RemotingInstrumentation.scala | 171 + ...decConstructMessageMethodInterceptor.scala | 2 +- ...tobufCodecDecodeMessageMethodAdvisor.scala | 7 +- .../internal/ArterySerializationAdvice.scala | 171 + .../ContextAwareWireFormats_Akka26.java | 2802 +++++++++++++++++ .../protobuf/ContextAwareWireFormats.proto | 30 + .../src/main/protobuf/WireFormats.proto | 132 + .../akka_26/DispatcherInstrumentation.scala | 120 + .../remote/RemotingInstrumentation.scala | 182 ++ ...decConstructMessageMethodInterceptor.scala | 81 + ...tobufCodecDecodeMessageMethodAdvisor.scala | 34 + .../internal/ArterySerializationAdvice.scala | 153 + .../ActorCellInvokeAdvice.java | 0 .../instrumentations/AkkaPrivateAccess.java | 0 .../common}/src/main/resources/reference.conf | 10 +- .../akka/AkkaClusterShardingMetrics.scala | 0 .../akka/AkkaInstrumentation.scala | 0 .../instrumentation/akka/AkkaMetrics.scala | 0 .../akka/AkkaRemoteInstrumentation.scala | 0 .../akka/AkkaRemoteMetrics.scala | 0 .../akka/instrumentations/ActorCellInfo.scala | 0 .../ActorInstrumentation.scala | 0 .../ActorLoggingInstrumentation.scala | 0 .../akka/instrumentations/ActorMonitor.scala | 0 .../ActorRefInstrumentation.scala | 0 .../AskPatternInstrumentation.scala | 0 .../instrumentations/DispatcherInfo.scala | 60 + .../EnvelopeInstrumentation.scala | 0 .../EventStreamInstrumentation.scala | 0 .../RouterInstrumentation.scala | 0 .../akka/instrumentations/RouterMonitor.scala | 0 .../SystemMessageInstrumentation.scala | 0 .../instrumentations/VersionFiltering.scala | 4 +- .../ReplaceWithMethodInterceptor.scala | 0 .../remote/MessageBufferInstrumentation.scala | 0 .../akka/remote/ShardingInstrumentation.scala | 0 .../akka/remote/internal/KamonOptionVal.scala | 0 .../akka/remote/RemotingInstrumentation.scala | 129 - .../remote/RemotingInstrumentationSpec.scala | 0 ...ArteryTcpRemotingInstrumentationSpec.scala | 162 + .../remote/RemotingInstrumentationSpec.scala | 181 ++ ...ArteryTcpRemotingInstrumentationSpec.scala | 160 + .../remote/RemotingInstrumentationSpec.scala | 189 ++ .../src/test/resources/application.conf | 0 .../common}/src/test/resources/logback.xml | 0 .../akka/ActorCellInstrumentationSpec.scala | 0 .../akka/ActorGroupMetricsSpec.scala | 0 .../ActorLoggingInstrumentationSpec.scala | 0 .../akka/ActorMetricsSpec.scala | 0 .../akka/ActorMetricsTestActor.scala | 0 .../akka/ActorSystemMetricsSpec.scala | 15 +- .../akka/AkkaTestKitInstrumentation.scala | 0 .../akka/AskPatternInstrumentationSpec.scala | 0 .../akka/AutoGroupingSpec.scala | 0 .../akka/ContextEchoActor.scala | 0 .../instrumentation/akka/ContextTesting.scala | 0 .../akka/DispatcherMetricsSpec.scala | 5 +- .../instrumentation/akka/EnvelopeSpec.scala | 0 .../akka/MessageTracingSpec.scala | 0 .../akka/RouterMetricsSpec.scala | 0 .../akka/RouterMetricsTestActor.scala | 0 .../SystemMessageInstrumentationSpec.scala | 0 .../akka/remote/MessageBufferTest.scala | 0 .../ShardingInstrumentationSpec.scala | 2 +- .../ShardingMessageBufferingSpec.scala | 4 +- 73 files changed, 4964 insertions(+), 376 deletions(-) rename {kamon-akka-bench => bench}/src/main/scala/kamon/instrumentation/akka/ActorCreationBench.scala (100%) rename {kamon-akka/src/main/java/akka/remote/instrumentation => instrumentation/akka-2.5/src/main/java/akka/remote}/ContextAwareWireFormats.java (90%) rename {kamon-akka => instrumentation/akka-2.5}/src/main/protobuf/ContextAwareWireFormats.proto (92%) rename {kamon-akka => instrumentation/akka-2.5}/src/main/protobuf/WireFormats.proto (100%) create mode 100644 instrumentation/akka-2.5/src/main/scala-2.11/kamon/instrumentation/akka/instrumentations/akka_26/DispatcherInstrumentation.scala create mode 100644 instrumentation/akka-2.5/src/main/scala-2.11/kamon/instrumentation/akka/instrumentations/akka_26/remote/RemotingInstrumentation.scala rename {kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations => instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25}/DispatcherInstrumentation.scala (74%) create mode 100644 instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/remote/RemotingInstrumentation.scala rename {kamon-akka/src/main/scala/kamon/instrumentation/akka => instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25}/remote/internal/AkkaPduProtobufCodecConstructMessageMethodInterceptor.scala (98%) rename {kamon-akka/src/main/scala/kamon/instrumentation/akka => instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25}/remote/internal/AkkaPduProtobufCodecDecodeMessageMethodAdvisor.scala (87%) create mode 100644 instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/remote/internal/ArterySerializationAdvice.scala create mode 100644 instrumentation/akka-2.6/src/main/java/akka/remote/ContextAwareWireFormats_Akka26.java create mode 100644 instrumentation/akka-2.6/src/main/protobuf/ContextAwareWireFormats.proto create mode 100644 instrumentation/akka-2.6/src/main/protobuf/WireFormats.proto create mode 100644 instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/DispatcherInstrumentation.scala create mode 100644 instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/RemotingInstrumentation.scala create mode 100644 instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/internal/AkkaPduProtobufCodecConstructMessageMethodInterceptor.scala create mode 100644 instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/internal/AkkaPduProtobufCodecDecodeMessageMethodAdvisor.scala create mode 100644 instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/internal/ArterySerializationAdvice.scala rename {kamon-akka => instrumentation/common}/src/main/java/kamon/instrumentation/akka/instrumentations/ActorCellInvokeAdvice.java (100%) rename {kamon-akka => instrumentation/common}/src/main/java/kamon/instrumentation/akka/instrumentations/AkkaPrivateAccess.java (100%) rename {kamon-akka => instrumentation/common}/src/main/resources/reference.conf (95%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/AkkaClusterShardingMetrics.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/AkkaInstrumentation.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/AkkaMetrics.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/AkkaRemoteInstrumentation.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/AkkaRemoteMetrics.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorCellInfo.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorInstrumentation.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorLoggingInstrumentation.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorMonitor.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorRefInstrumentation.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/instrumentations/AskPatternInstrumentation.scala (100%) create mode 100644 instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/DispatcherInfo.scala rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/instrumentations/EnvelopeInstrumentation.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/instrumentations/EventStreamInstrumentation.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/instrumentations/RouterInstrumentation.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/instrumentations/RouterMonitor.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/instrumentations/SystemMessageInstrumentation.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/instrumentations/VersionFiltering.scala (83%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/instrumentations/internal/ReplaceWithMethodInterceptor.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/remote/MessageBufferInstrumentation.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/remote/ShardingInstrumentation.scala (100%) rename {kamon-akka => instrumentation/common}/src/main/scala/kamon/instrumentation/akka/remote/internal/KamonOptionVal.scala (100%) delete mode 100644 kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/RemotingInstrumentation.scala rename {kamon-akka-common-tests => test/akka-2.4}/src/test/scala/kamon/instrumentation/akka/remote/RemotingInstrumentationSpec.scala (100%) create mode 100644 test/akka-2.5/src/test/scala/kamon/instrumentation/akka/remote/ArteryTcpRemotingInstrumentationSpec.scala create mode 100644 test/akka-2.5/src/test/scala/kamon/instrumentation/akka/remote/RemotingInstrumentationSpec.scala create mode 100644 test/akka-2.6/src/test/scala/kamon/instrumentation/akka/remote/ArteryTcpRemotingInstrumentationSpec.scala create mode 100644 test/akka-2.6/src/test/scala/kamon/instrumentation/akka/remote/RemotingInstrumentationSpec.scala rename {kamon-akka-common-tests => test/common}/src/test/resources/application.conf (100%) rename {kamon-akka-common-tests => test/common}/src/test/resources/logback.xml (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/ActorCellInstrumentationSpec.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/ActorGroupMetricsSpec.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/ActorLoggingInstrumentationSpec.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/ActorMetricsSpec.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/ActorMetricsTestActor.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/ActorSystemMetricsSpec.scala (89%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/AkkaTestKitInstrumentation.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/AskPatternInstrumentationSpec.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/AutoGroupingSpec.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/ContextEchoActor.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/ContextTesting.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/DispatcherMetricsSpec.scala (96%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/EnvelopeSpec.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/MessageTracingSpec.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/RouterMetricsSpec.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/RouterMetricsTestActor.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/SystemMessageInstrumentationSpec.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/remote/MessageBufferTest.scala (100%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/sharding/ShardingInstrumentationSpec.scala (99%) rename {kamon-akka-common-tests => test/common}/src/test/scala/kamon/instrumentation/akka/sharding/ShardingMessageBufferingSpec.scala (98%) diff --git a/kamon-akka-bench/src/main/scala/kamon/instrumentation/akka/ActorCreationBench.scala b/bench/src/main/scala/kamon/instrumentation/akka/ActorCreationBench.scala similarity index 100% rename from kamon-akka-bench/src/main/scala/kamon/instrumentation/akka/ActorCreationBench.scala rename to bench/src/main/scala/kamon/instrumentation/akka/ActorCreationBench.scala diff --git a/build.sbt b/build.sbt index 82f1a30..e7f7a65 100644 --- a/build.sbt +++ b/build.sbt @@ -19,10 +19,11 @@ val kamonTestkit = "io.kamon" %% "kamon-testkit" % "2.0.0" val kamonScala = "io.kamon" %% "kamon-scala-future" % "2.0.0" val kamonExecutors = "io.kamon" %% "kamon-executors" % "2.0.0" val kamonInstrument = "io.kamon" %% "kamon-instrumentation-common" % "2.0.0" -val kanelaAgent = "io.kamon" % "kanela-agent" % "1.0.0" +val kanelaAgent = "io.kamon" % "kanela-agent" % "1.0.3" val akka24Version = "2.4.20" -val akka25Version = "2.5.24" +val akka25Version = "2.5.26" +val akka26Version = "2.6.0" val akkaActor = "com.typesafe.akka" %% "akka-actor" % akka25Version val akkaTestkit = "com.typesafe.akka" %% "akka-testkit" % akka25Version @@ -30,29 +31,89 @@ val akkaSLF4J = "com.typesafe.akka" %% "akka-slf4j" % akka25 val akkaRemote = "com.typesafe.akka" %% "akka-remote" % akka25Version val akkaCluster = "com.typesafe.akka" %% "akka-cluster" % akka25Version val akkaSharding = "com.typesafe.akka" %% "akka-cluster-sharding" % akka25Version +val akkaProtobuf = "com.typesafe.akka" %% "akka-protobuf" % akka25Version +val netty = "io.netty" % "netty" % "3.10.6.Final" -lazy val root = (project in file(".")) +kanelaAgentVersion in ThisBuild := "1.0.3" + +lazy val root = Project("kamon-akka", file(".")) .settings(noPublishing) .settings(crossScalaVersions := Nil) - .aggregate(instrumentation, commonTests, testsOnAkka24, testsOnAkka25, benchmarks) + .aggregate( + testCommon, + testsOnAkka24, + testsOnAkka25, + testsOnAkka26, + benchmarks, + instrumentation, + instrumentationCommon, + instrumentation25, + instrumentation26, + ) + + +lazy val instrumentationCommon = Project("instrumentation-common", file("instrumentation/common")) + .settings(noPublishing: _*) + .settings( + scalacOptions += "-target:jvm-1.8", + scalaVersion := "2.12.8", + crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.1"), + libraryDependencies ++= + compileScope(kamonCore, kamonInstrument, kamonScala, kamonExecutors) ++ + providedScope(akkaActor, akkaRemote, akkaProtobuf, akkaCluster, akkaSharding, kanelaAgent)) + +lazy val instrumentation25 = Project("instrumentation-25", file("instrumentation/akka-2.5")) + .settings(noPublishing: _*) + .dependsOn(instrumentationCommon) + .settings( + scalacOptions += "-target:jvm-1.8", + scalaVersion := "2.12.8", + crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.1"), + libraryDependencies ++= + compileScope(kamonCore, kamonInstrument, kamonScala, kamonExecutors) ++ + providedScope(akkaActor, akkaRemote, akkaProtobuf, akkaCluster, akkaSharding, kanelaAgent)) + +lazy val instrumentation26 = Project("instrumentation-26", file("instrumentation/akka-2.6")) + .settings(noPublishing: _*) + .dependsOn(instrumentationCommon) + .settings( + scalacOptions += "-target:jvm-1.8", + scalaVersion := "2.12.8", + crossScalaVersions := Seq("2.12.8", "2.13.1"), + libraryDependencies ++= + compileScope(kamonCore, kamonInstrument, kamonScala, kamonExecutors) ++ + providedScope(onAkka26(akkaActor, akkaRemote, akkaProtobuf, akkaCluster, akkaSharding) :+ kanelaAgent: _*)) + // These common modules contains all the stuff that can be reused between different Akka versions. They compile with // Akka 2.4, but the actual modules for each Akka version are only using the sources from these project instead of the // compiled classes. This is just to ensure that if there are any binary incompatible changes between Akka 2.4 and 2.5 // at the internal level, we will still be compiling and testing with the right versions. // -lazy val instrumentation = Project("instrumentation", file("kamon-akka")) +lazy val instrumentation = Project("instrumentation", file("instrumentation")) .settings( moduleName := "kamon-akka", bintrayPackage := "kamon-akka", scalacOptions += "-target:jvm-1.8", scalaVersion := "2.12.8", - crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.0"), - libraryDependencies ++= - compileScope(kamonCore, kamonInstrument, kamonScala, kamonExecutors) ++ - providedScope(akkaActor, akkaRemote, akkaCluster, akkaSharding, kanelaAgent)) + crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.1"), + libraryDependencies ++= compileScope(kamonCore, kamonInstrument, kamonScala, kamonExecutors), + products in Compile := (Def.taskDyn { + if (scalaBinaryVersion.value == "2.11") { + Def.task { + (products in Compile in instrumentationCommon).value ++ + (products in Compile in instrumentation25).value + } + } else { + Def.task { + (products in Compile in instrumentationCommon).value ++ + (products in Compile in instrumentation25).value ++ + (products in Compile in instrumentation26).value + } + } + }).value) -lazy val commonTests = Project("common-tests", file("kamon-akka-common-tests")) +lazy val testCommon = Project("test-common", file("test/common")) .dependsOn(instrumentation) .settings(noPublishing: _*) .settings( @@ -60,56 +121,72 @@ lazy val commonTests = Project("common-tests", file("kamon-akka-common-tests")) testOnly := ((): Unit), testQuick := ((): Unit), scalaVersion := "2.12.8", - crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.0"), + crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.1"), libraryDependencies ++= compileScope(kamonCore, kamonInstrument, kamonScala, kamonExecutors) ++ providedScope(akkaActor, kanelaAgent) ++ testScope(scalatest, kamonTestkit, akkaTestkit, akkaSLF4J, logbackClassic)) -lazy val testsOnAkka24 = Project("kamon-akka-tests-24", file("kamon-akka-tests-2.4")) +lazy val testsOnAkka24 = Project("test-24", file("test/akka-2.4")) .dependsOn(instrumentation) .enablePlugins(JavaAgent) .settings(instrumentationSettings) .settings(noPublishing: _*) .settings( - name := "kamon-akka-tests-2.4", scalaVersion := "2.12.8", crossScalaVersions := Seq("2.11.12", "2.12.8"), testGrouping in Test := removeUnsupportedTests((definedTests in Test).value, kanelaAgentJar.value), - unmanagedSourceDirectories in Test ++= (unmanagedSourceDirectories in Test in commonTests).value, - unmanagedResourceDirectories in Test ++= (unmanagedResourceDirectories in Test in commonTests).value, + unmanagedSourceDirectories in Test ++= (unmanagedSourceDirectories in Test in testCommon).value, + unmanagedResourceDirectories in Test ++= (unmanagedResourceDirectories in Test in testCommon).value, libraryDependencies ++= providedScope(onAkka24(akkaActor), onAkka24(akkaRemote), onAkka24(akkaCluster), onAkka24(akkaSharding), kanelaAgent) ++ testScope(scalatest, kamonTestkit, onAkka24(akkaTestkit), onAkka24(akkaSLF4J), logbackClassic)) -lazy val testsOnAkka25 = Project("kamon-akka-tests-25", file("kamon-akka-tests-2.5")) +lazy val testsOnAkka25 = Project("test-25", file("test/akka-2.5")) .dependsOn(instrumentation) .enablePlugins(JavaAgent) .settings(instrumentationSettings) .settings(noPublishing: _*) .settings( - name := "kamon-akka-tests-2.5", scalaVersion := "2.12.8", - crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.0"), - unmanagedSourceDirectories in Test ++= (unmanagedSourceDirectories in Test in commonTests).value, - unmanagedResourceDirectories in Test ++= (unmanagedResourceDirectories in Test in commonTests).value, + crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.1"), + unmanagedSourceDirectories in Test ++= (unmanagedSourceDirectories in Test in testCommon).value, + unmanagedResourceDirectories in Test ++= (unmanagedResourceDirectories in Test in testCommon).value, libraryDependencies ++= providedScope(akkaActor, akkaRemote, akkaCluster, akkaSharding, kanelaAgent) ++ testScope(scalatest, kamonTestkit, akkaTestkit, akkaSLF4J, logbackClassic)) -lazy val benchmarks = Project("benchmarks", file("kamon-akka-bench")) +lazy val testsOnAkka26 = Project("test-26", file("test/akka-2.6")) + .dependsOn(instrumentation) + .enablePlugins(JavaAgent) + .settings(instrumentationSettings) + .settings(noPublishing: _*) + .settings( + scalaVersion := "2.12.8", + crossScalaVersions := Seq("2.12.8", "2.13.1"), + testGrouping in Test := removeUnsupportedTests((definedTests in Test).value, kanelaAgentJar.value), + unmanagedSourceDirectories in Test ++= (unmanagedSourceDirectories in Test in testCommon).value, + unmanagedResourceDirectories in Test ++= (unmanagedResourceDirectories in Test in testCommon).value, + libraryDependencies ++= + providedScope(onAkka26(akkaActor, akkaRemote, akkaCluster, akkaSharding) ++ Seq(kanelaAgent, netty): _*) ++ + testScope(onAkka26(akkaTestkit, akkaSLF4J) ++ Seq(scalatest, kamonTestkit, logbackClassic): _*)) + +lazy val benchmarks = Project("benchmarks", file("bench")) .enablePlugins(JmhPlugin) .dependsOn(instrumentation) .settings(noPublishing: _*) .settings( scalaVersion := "2.12.8", - crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.0"), + crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.1"), libraryDependencies ++= compileScope(akkaActor, akkaRemote, akkaCluster, akkaSharding, kanelaAgent)) def onAkka24(moduleID: ModuleID): ModuleID = moduleID.withRevision(akka24Version) +def onAkka26(moduleIDs: ModuleID*): Seq[ModuleID] = + moduleIDs.map(_.withRevision(akka26Version)) + def removeUnsupportedTests(tests: Seq[TestDefinition], kanelaJar: File): Seq[Group] = { val excludedFeatures = Seq("sharding") diff --git a/kamon-akka/src/main/java/akka/remote/instrumentation/ContextAwareWireFormats.java b/instrumentation/akka-2.5/src/main/java/akka/remote/ContextAwareWireFormats.java similarity index 90% rename from kamon-akka/src/main/java/akka/remote/instrumentation/ContextAwareWireFormats.java rename to instrumentation/akka-2.5/src/main/java/akka/remote/ContextAwareWireFormats.java index 7de41fe..8a607c3 100644 --- a/kamon-akka/src/main/java/akka/remote/instrumentation/ContextAwareWireFormats.java +++ b/instrumentation/akka-2.5/src/main/java/akka/remote/ContextAwareWireFormats.java @@ -64,7 +64,7 @@ public AckAndContextAwareEnvelopeContainer getDefaultInstanceForType() { private final akka.protobuf.UnknownFieldSet unknownFields; @java.lang.Override public final akka.protobuf.UnknownFieldSet - getUnknownFields() { + getUnknownFields() { return this.unknownFields; } private AckAndContextAwareEnvelopeContainer( @@ -85,7 +85,7 @@ private AckAndContextAwareEnvelopeContainer( break; default: { if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { + extensionRegistry, tag)) { done = true; } break; @@ -129,12 +129,12 @@ private AckAndContextAwareEnvelopeContainer( } } public static final akka.protobuf.Descriptors.Descriptor - getDescriptor() { + getDescriptor() { return ContextAwareWireFormats.internal_static_AckAndTraceContextAwareEnvelopeContainer_descriptor; } protected akka.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { + internalGetFieldAccessorTable() { return ContextAwareWireFormats.internal_static_AckAndTraceContextAwareEnvelopeContainer_fieldAccessorTable .ensureFieldAccessorsInitialized( AckAndContextAwareEnvelopeContainer.class, AckAndContextAwareEnvelopeContainer.Builder.class); @@ -142,13 +142,13 @@ private AckAndContextAwareEnvelopeContainer( public static akka.protobuf.Parser PARSER = new akka.protobuf.AbstractParser() { - public AckAndContextAwareEnvelopeContainer parsePartialFrom( - akka.protobuf.CodedInputStream input, - akka.protobuf.ExtensionRegistryLite extensionRegistry) - throws akka.protobuf.InvalidProtocolBufferException { - return new AckAndContextAwareEnvelopeContainer(input, extensionRegistry); - } - }; + public AckAndContextAwareEnvelopeContainer parsePartialFrom( + akka.protobuf.CodedInputStream input, + akka.protobuf.ExtensionRegistryLite extensionRegistry) + throws akka.protobuf.InvalidProtocolBufferException { + return new AckAndContextAwareEnvelopeContainer(input, extensionRegistry); + } + }; @java.lang.Override public akka.protobuf.Parser getParserForType() { @@ -226,7 +226,7 @@ public final boolean isInitialized() { } public void writeTo(akka.protobuf.CodedOutputStream output) - throws java.io.IOException { + throws java.io.IOException { getSerializedSize(); if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeMessage(1, ack_); @@ -245,11 +245,11 @@ public int getSerializedSize() { size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += akka.protobuf.CodedOutputStream - .computeMessageSize(1, ack_); + .computeMessageSize(1, ack_); } if (((bitField0_ & 0x00000002) == 0x00000002)) { size += akka.protobuf.CodedOutputStream - .computeMessageSize(2, envelope_); + .computeMessageSize(2, envelope_); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -334,14 +334,14 @@ protected Builder newBuilderForType( */ public static final class Builder extends akka.protobuf.GeneratedMessage.Builder - implements ContextAwareWireFormats.AckAndTraceContextAwareEnvelopeContainerOrBuilder { + implements ContextAwareWireFormats.AckAndTraceContextAwareEnvelopeContainerOrBuilder { public static final akka.protobuf.Descriptors.Descriptor - getDescriptor() { + getDescriptor() { return ContextAwareWireFormats.internal_static_AckAndTraceContextAwareEnvelopeContainer_descriptor; } protected akka.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { + internalGetFieldAccessorTable() { return ContextAwareWireFormats.internal_static_AckAndTraceContextAwareEnvelopeContainer_fieldAccessorTable .ensureFieldAccessorsInitialized( AckAndContextAwareEnvelopeContainer.class, AckAndContextAwareEnvelopeContainer.Builder.class); @@ -389,7 +389,7 @@ public Builder clone() { } public akka.protobuf.Descriptors.Descriptor - getDescriptorForType() { + getDescriptorForType() { return ContextAwareWireFormats.internal_static_AckAndTraceContextAwareEnvelopeContainer_descriptor; } @@ -454,13 +454,13 @@ public Builder mergeFrom(AckAndContextAwareEnvelopeContainer other) { public final boolean isInitialized() { if (hasAck()) { if (!getAck().isInitialized()) { - + return false; } } if (hasEnvelope()) { if (!getEnvelope().isInitialized()) { - + return false; } } @@ -544,7 +544,7 @@ public Builder mergeAck(akka.remote.WireFormats.AcknowledgementInfo value) { if (((bitField0_ & 0x00000001) == 0x00000001) && ack_ != akka.remote.WireFormats.AcknowledgementInfo.getDefaultInstance()) { ack_ = - akka.remote.WireFormats.AcknowledgementInfo.newBuilder(ack_).mergeFrom(value).buildPartial(); + akka.remote.WireFormats.AcknowledgementInfo.newBuilder(ack_).mergeFrom(value).buildPartial(); } else { ack_ = value; } @@ -590,14 +590,14 @@ public akka.remote.WireFormats.AcknowledgementInfoOrBuilder getAckOrBuilder() { * optional .AcknowledgementInfo ack = 1; */ private akka.protobuf.SingleFieldBuilder< - akka.remote.WireFormats.AcknowledgementInfo, akka.remote.WireFormats.AcknowledgementInfo.Builder, akka.remote.WireFormats.AcknowledgementInfoOrBuilder> - getAckFieldBuilder() { + akka.remote.WireFormats.AcknowledgementInfo, akka.remote.WireFormats.AcknowledgementInfo.Builder, akka.remote.WireFormats.AcknowledgementInfoOrBuilder> + getAckFieldBuilder() { if (ackBuilder_ == null) { ackBuilder_ = new akka.protobuf.SingleFieldBuilder< akka.remote.WireFormats.AcknowledgementInfo, akka.remote.WireFormats.AcknowledgementInfo.Builder, akka.remote.WireFormats.AcknowledgementInfoOrBuilder>( - ack_, - getParentForChildren(), - isClean()); + ack_, + getParentForChildren(), + isClean()); ack_ = null; } return ackBuilder_; @@ -606,7 +606,7 @@ public akka.remote.WireFormats.AcknowledgementInfoOrBuilder getAckOrBuilder() { // optional .ContextAwareRemoteEnvelope envelope = 2; private ContextAwareRemoteEnvelope envelope_ = ContextAwareRemoteEnvelope.getDefaultInstance(); private akka.protobuf.SingleFieldBuilder< - ContextAwareRemoteEnvelope, ContextAwareRemoteEnvelope.Builder, ContextAwareWireFormats.TraceContextAwareRemoteEnvelopeOrBuilder> envelopeBuilder_; + ContextAwareRemoteEnvelope, ContextAwareRemoteEnvelope.Builder, ContextAwareWireFormats.TraceContextAwareRemoteEnvelopeOrBuilder> envelopeBuilder_; /** * optional .ContextAwareRemoteEnvelope envelope = 2; */ @@ -661,7 +661,7 @@ public Builder mergeEnvelope(ContextAwareRemoteEnvelope value) { if (((bitField0_ & 0x00000002) == 0x00000002) && envelope_ != ContextAwareRemoteEnvelope.getDefaultInstance()) { envelope_ = - ContextAwareRemoteEnvelope.newBuilder(envelope_).mergeFrom(value).buildPartial(); + ContextAwareRemoteEnvelope.newBuilder(envelope_).mergeFrom(value).buildPartial(); } else { envelope_ = value; } @@ -707,14 +707,14 @@ public ContextAwareWireFormats.TraceContextAwareRemoteEnvelopeOrBuilder getEnvel * optional .ContextAwareRemoteEnvelope envelope = 2; */ private akka.protobuf.SingleFieldBuilder< - ContextAwareRemoteEnvelope, ContextAwareRemoteEnvelope.Builder, ContextAwareWireFormats.TraceContextAwareRemoteEnvelopeOrBuilder> - getEnvelopeFieldBuilder() { + ContextAwareRemoteEnvelope, ContextAwareRemoteEnvelope.Builder, ContextAwareWireFormats.TraceContextAwareRemoteEnvelopeOrBuilder> + getEnvelopeFieldBuilder() { if (envelopeBuilder_ == null) { envelopeBuilder_ = new akka.protobuf.SingleFieldBuilder< - ContextAwareRemoteEnvelope, ContextAwareRemoteEnvelope.Builder, ContextAwareWireFormats.TraceContextAwareRemoteEnvelopeOrBuilder>( - envelope_, - getParentForChildren(), - isClean()); + ContextAwareRemoteEnvelope, ContextAwareRemoteEnvelope.Builder, ContextAwareWireFormats.TraceContextAwareRemoteEnvelopeOrBuilder>( + envelope_, + getParentForChildren(), + isClean()); envelope_ = null; } return envelopeBuilder_; @@ -825,7 +825,7 @@ public ContextAwareRemoteEnvelope getDefaultInstanceForType() { private final akka.protobuf.UnknownFieldSet unknownFields; @java.lang.Override public final akka.protobuf.UnknownFieldSet - getUnknownFields() { + getUnknownFields() { return this.unknownFields; } private ContextAwareRemoteEnvelope( @@ -846,7 +846,7 @@ private ContextAwareRemoteEnvelope( break; default: { if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { + extensionRegistry, tag)) { done = true; } break; @@ -921,12 +921,12 @@ private ContextAwareRemoteEnvelope( } } public static final akka.protobuf.Descriptors.Descriptor - getDescriptor() { + getDescriptor() { return ContextAwareWireFormats.internal_static_TraceContextAwareRemoteEnvelope_descriptor; } protected akka.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { + internalGetFieldAccessorTable() { return ContextAwareWireFormats.internal_static_TraceContextAwareRemoteEnvelope_fieldAccessorTable .ensureFieldAccessorsInitialized( ContextAwareRemoteEnvelope.class, ContextAwareRemoteEnvelope.Builder.class); @@ -934,13 +934,13 @@ private ContextAwareRemoteEnvelope( public static akka.protobuf.Parser PARSER = new akka.protobuf.AbstractParser() { - public ContextAwareRemoteEnvelope parsePartialFrom( - akka.protobuf.CodedInputStream input, - akka.protobuf.ExtensionRegistryLite extensionRegistry) - throws akka.protobuf.InvalidProtocolBufferException { - return new ContextAwareRemoteEnvelope(input, extensionRegistry); - } - }; + public ContextAwareRemoteEnvelope parsePartialFrom( + akka.protobuf.CodedInputStream input, + akka.protobuf.ExtensionRegistryLite extensionRegistry) + throws akka.protobuf.InvalidProtocolBufferException { + return new ContextAwareRemoteEnvelope(input, extensionRegistry); + } + }; @java.lang.Override public akka.protobuf.Parser getParserForType() { @@ -1097,7 +1097,7 @@ public final boolean isInitialized() { } public void writeTo(akka.protobuf.CodedOutputStream output) - throws java.io.IOException { + throws java.io.IOException { getSerializedSize(); if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeMessage(1, recipient_); @@ -1125,23 +1125,23 @@ public int getSerializedSize() { size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += akka.protobuf.CodedOutputStream - .computeMessageSize(1, recipient_); + .computeMessageSize(1, recipient_); } if (((bitField0_ & 0x00000002) == 0x00000002)) { size += akka.protobuf.CodedOutputStream - .computeMessageSize(2, message_); + .computeMessageSize(2, message_); } if (((bitField0_ & 0x00000004) == 0x00000004)) { size += akka.protobuf.CodedOutputStream - .computeMessageSize(4, sender_); + .computeMessageSize(4, sender_); } if (((bitField0_ & 0x00000008) == 0x00000008)) { size += akka.protobuf.CodedOutputStream - .computeFixed64Size(5, seq_); + .computeFixed64Size(5, seq_); } if (((bitField0_ & 0x00000010) == 0x00000010)) { size += akka.protobuf.CodedOutputStream - .computeMessageSize(15, traceContext_); + .computeMessageSize(15, traceContext_); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -1226,14 +1226,14 @@ protected Builder newBuilderForType( */ public static final class Builder extends akka.protobuf.GeneratedMessage.Builder - implements ContextAwareWireFormats.TraceContextAwareRemoteEnvelopeOrBuilder { + implements ContextAwareWireFormats.TraceContextAwareRemoteEnvelopeOrBuilder { public static final akka.protobuf.Descriptors.Descriptor - getDescriptor() { + getDescriptor() { return ContextAwareWireFormats.internal_static_TraceContextAwareRemoteEnvelope_descriptor; } protected akka.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { + internalGetFieldAccessorTable() { return ContextAwareWireFormats.internal_static_TraceContextAwareRemoteEnvelope_fieldAccessorTable .ensureFieldAccessorsInitialized( ContextAwareRemoteEnvelope.class, ContextAwareRemoteEnvelope.Builder.class); @@ -1297,7 +1297,7 @@ public Builder clone() { } public akka.protobuf.Descriptors.Descriptor - getDescriptorForType() { + getDescriptorForType() { return ContextAwareWireFormats.internal_static_TraceContextAwareRemoteEnvelope_descriptor; } @@ -1390,30 +1390,30 @@ public Builder mergeFrom(ContextAwareRemoteEnvelope other) { public final boolean isInitialized() { if (!hasRecipient()) { - + return false; } if (!hasMessage()) { - + return false; } if (!getRecipient().isInitialized()) { - + return false; } if (!getMessage().isInitialized()) { - + return false; } if (hasSender()) { if (!getSender().isInitialized()) { - + return false; } } if (hasTraceContext()) { if (!getTraceContext().isInitialized()) { - + return false; } } @@ -1497,7 +1497,7 @@ public Builder mergeRecipient(akka.remote.WireFormats.ActorRefData value) { if (((bitField0_ & 0x00000001) == 0x00000001) && recipient_ != akka.remote.WireFormats.ActorRefData.getDefaultInstance()) { recipient_ = - akka.remote.WireFormats.ActorRefData.newBuilder(recipient_).mergeFrom(value).buildPartial(); + akka.remote.WireFormats.ActorRefData.newBuilder(recipient_).mergeFrom(value).buildPartial(); } else { recipient_ = value; } @@ -1543,14 +1543,14 @@ public akka.remote.WireFormats.ActorRefDataOrBuilder getRecipientOrBuilder() { * required .ActorRefData recipient = 1; */ private akka.protobuf.SingleFieldBuilder< - akka.remote.WireFormats.ActorRefData, akka.remote.WireFormats.ActorRefData.Builder, akka.remote.WireFormats.ActorRefDataOrBuilder> - getRecipientFieldBuilder() { + akka.remote.WireFormats.ActorRefData, akka.remote.WireFormats.ActorRefData.Builder, akka.remote.WireFormats.ActorRefDataOrBuilder> + getRecipientFieldBuilder() { if (recipientBuilder_ == null) { recipientBuilder_ = new akka.protobuf.SingleFieldBuilder< akka.remote.WireFormats.ActorRefData, akka.remote.WireFormats.ActorRefData.Builder, akka.remote.WireFormats.ActorRefDataOrBuilder>( - recipient_, - getParentForChildren(), - isClean()); + recipient_, + getParentForChildren(), + isClean()); recipient_ = null; } return recipientBuilder_; @@ -1614,7 +1614,7 @@ public Builder mergeMessage(akka.remote.WireFormats.SerializedMessage value) { if (((bitField0_ & 0x00000002) == 0x00000002) && message_ != akka.remote.WireFormats.SerializedMessage.getDefaultInstance()) { message_ = - akka.remote.WireFormats.SerializedMessage.newBuilder(message_).mergeFrom(value).buildPartial(); + akka.remote.WireFormats.SerializedMessage.newBuilder(message_).mergeFrom(value).buildPartial(); } else { message_ = value; } @@ -1660,14 +1660,14 @@ public akka.remote.WireFormats.SerializedMessageOrBuilder getMessageOrBuilder() * required .SerializedMessage message = 2; */ private akka.protobuf.SingleFieldBuilder< - akka.remote.WireFormats.SerializedMessage, akka.remote.WireFormats.SerializedMessage.Builder, akka.remote.WireFormats.SerializedMessageOrBuilder> - getMessageFieldBuilder() { + akka.remote.WireFormats.SerializedMessage, akka.remote.WireFormats.SerializedMessage.Builder, akka.remote.WireFormats.SerializedMessageOrBuilder> + getMessageFieldBuilder() { if (messageBuilder_ == null) { messageBuilder_ = new akka.protobuf.SingleFieldBuilder< akka.remote.WireFormats.SerializedMessage, akka.remote.WireFormats.SerializedMessage.Builder, akka.remote.WireFormats.SerializedMessageOrBuilder>( - message_, - getParentForChildren(), - isClean()); + message_, + getParentForChildren(), + isClean()); message_ = null; } return messageBuilder_; @@ -1731,7 +1731,7 @@ public Builder mergeSender(akka.remote.WireFormats.ActorRefData value) { if (((bitField0_ & 0x00000004) == 0x00000004) && sender_ != akka.remote.WireFormats.ActorRefData.getDefaultInstance()) { sender_ = - akka.remote.WireFormats.ActorRefData.newBuilder(sender_).mergeFrom(value).buildPartial(); + akka.remote.WireFormats.ActorRefData.newBuilder(sender_).mergeFrom(value).buildPartial(); } else { sender_ = value; } @@ -1777,14 +1777,14 @@ public akka.remote.WireFormats.ActorRefDataOrBuilder getSenderOrBuilder() { * optional .ActorRefData sender = 4; */ private akka.protobuf.SingleFieldBuilder< - akka.remote.WireFormats.ActorRefData, akka.remote.WireFormats.ActorRefData.Builder, akka.remote.WireFormats.ActorRefDataOrBuilder> - getSenderFieldBuilder() { + akka.remote.WireFormats.ActorRefData, akka.remote.WireFormats.ActorRefData.Builder, akka.remote.WireFormats.ActorRefDataOrBuilder> + getSenderFieldBuilder() { if (senderBuilder_ == null) { senderBuilder_ = new akka.protobuf.SingleFieldBuilder< akka.remote.WireFormats.ActorRefData, akka.remote.WireFormats.ActorRefData.Builder, akka.remote.WireFormats.ActorRefDataOrBuilder>( - sender_, - getParentForChildren(), - isClean()); + sender_, + getParentForChildren(), + isClean()); sender_ = null; } return senderBuilder_; @@ -1826,7 +1826,7 @@ public Builder clearSeq() { // optional .RemoteContext traceContext = 15; private RemoteContext traceContext_ = RemoteContext.getDefaultInstance(); private akka.protobuf.SingleFieldBuilder< - RemoteContext, RemoteContext.Builder, ContextAwareWireFormats.RemoteTraceContextOrBuilder> traceContextBuilder_; + RemoteContext, RemoteContext.Builder, ContextAwareWireFormats.RemoteTraceContextOrBuilder> traceContextBuilder_; /** * optional .RemoteContext traceContext = 15; */ @@ -1881,7 +1881,7 @@ public Builder mergeTraceContext(RemoteContext value) { if (((bitField0_ & 0x00000010) == 0x00000010) && traceContext_ != RemoteContext.getDefaultInstance()) { traceContext_ = - RemoteContext.newBuilder(traceContext_).mergeFrom(value).buildPartial(); + RemoteContext.newBuilder(traceContext_).mergeFrom(value).buildPartial(); } else { traceContext_ = value; } @@ -1927,14 +1927,14 @@ public ContextAwareWireFormats.RemoteTraceContextOrBuilder getTraceContextOrBuil * optional .RemoteContext traceContext = 15; */ private akka.protobuf.SingleFieldBuilder< - RemoteContext, RemoteContext.Builder, ContextAwareWireFormats.RemoteTraceContextOrBuilder> - getTraceContextFieldBuilder() { + RemoteContext, RemoteContext.Builder, ContextAwareWireFormats.RemoteTraceContextOrBuilder> + getTraceContextFieldBuilder() { if (traceContextBuilder_ == null) { traceContextBuilder_ = new akka.protobuf.SingleFieldBuilder< - RemoteContext, RemoteContext.Builder, ContextAwareWireFormats.RemoteTraceContextOrBuilder>( - traceContext_, - getParentForChildren(), - isClean()); + RemoteContext, RemoteContext.Builder, ContextAwareWireFormats.RemoteTraceContextOrBuilder>( + traceContext_, + getParentForChildren(), + isClean()); traceContext_ = null; } return traceContextBuilder_; @@ -1989,7 +1989,7 @@ public RemoteContext getDefaultInstanceForType() { private final akka.protobuf.UnknownFieldSet unknownFields; @java.lang.Override public final akka.protobuf.UnknownFieldSet - getUnknownFields() { + getUnknownFields() { return this.unknownFields; } private RemoteContext( @@ -2010,7 +2010,7 @@ private RemoteContext( break; default: { if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { + extensionRegistry, tag)) { done = true; } break; @@ -2033,12 +2033,12 @@ private RemoteContext( } } public static final akka.protobuf.Descriptors.Descriptor - getDescriptor() { + getDescriptor() { return ContextAwareWireFormats.internal_static_RemoteTraceContext_descriptor; } protected akka.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { + internalGetFieldAccessorTable() { return ContextAwareWireFormats.internal_static_RemoteTraceContext_fieldAccessorTable .ensureFieldAccessorsInitialized( RemoteContext.class, RemoteContext.Builder.class); @@ -2046,13 +2046,13 @@ private RemoteContext( public static akka.protobuf.Parser PARSER = new akka.protobuf.AbstractParser() { - public RemoteContext parsePartialFrom( - akka.protobuf.CodedInputStream input, - akka.protobuf.ExtensionRegistryLite extensionRegistry) - throws akka.protobuf.InvalidProtocolBufferException { - return new RemoteContext(input, extensionRegistry); - } - }; + public RemoteContext parsePartialFrom( + akka.protobuf.CodedInputStream input, + akka.protobuf.ExtensionRegistryLite extensionRegistry) + throws akka.protobuf.InvalidProtocolBufferException { + return new RemoteContext(input, extensionRegistry); + } + }; @java.lang.Override public akka.protobuf.Parser getParserForType() { @@ -2093,7 +2093,7 @@ public final boolean isInitialized() { } public void writeTo(akka.protobuf.CodedOutputStream output) - throws java.io.IOException { + throws java.io.IOException { getSerializedSize(); if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeBytes(1, context_); @@ -2109,7 +2109,7 @@ public int getSerializedSize() { size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += akka.protobuf.CodedOutputStream - .computeBytesSize(1, context_); + .computeBytesSize(1, context_); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -2194,14 +2194,14 @@ protected Builder newBuilderForType( */ public static final class Builder extends akka.protobuf.GeneratedMessage.Builder - implements ContextAwareWireFormats.RemoteTraceContextOrBuilder { + implements ContextAwareWireFormats.RemoteTraceContextOrBuilder { public static final akka.protobuf.Descriptors.Descriptor - getDescriptor() { + getDescriptor() { return ContextAwareWireFormats.internal_static_RemoteTraceContext_descriptor; } protected akka.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { + internalGetFieldAccessorTable() { return ContextAwareWireFormats.internal_static_RemoteTraceContext_fieldAccessorTable .ensureFieldAccessorsInitialized( RemoteContext.class, RemoteContext.Builder.class); @@ -2237,7 +2237,7 @@ public Builder clone() { } public akka.protobuf.Descriptors.Descriptor - getDescriptorForType() { + getDescriptorForType() { return ContextAwareWireFormats.internal_static_RemoteTraceContext_descriptor; } @@ -2286,7 +2286,7 @@ public Builder mergeFrom(RemoteContext other) { public final boolean isInitialized() { if (!hasContext()) { - + return false; } return true; @@ -2330,9 +2330,9 @@ public akka.protobuf.ByteString getContext() { */ public Builder setContext(akka.protobuf.ByteString value) { if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; context_ = value; onChanged(); return this; @@ -2359,74 +2359,74 @@ public Builder clearContext() { } private static akka.protobuf.Descriptors.Descriptor - internal_static_AckAndTraceContextAwareEnvelopeContainer_descriptor; + internal_static_AckAndTraceContextAwareEnvelopeContainer_descriptor; private static - akka.protobuf.GeneratedMessage.FieldAccessorTable + akka.protobuf.GeneratedMessage.FieldAccessorTable internal_static_AckAndTraceContextAwareEnvelopeContainer_fieldAccessorTable; private static akka.protobuf.Descriptors.Descriptor - internal_static_TraceContextAwareRemoteEnvelope_descriptor; + internal_static_TraceContextAwareRemoteEnvelope_descriptor; private static - akka.protobuf.GeneratedMessage.FieldAccessorTable + akka.protobuf.GeneratedMessage.FieldAccessorTable internal_static_TraceContextAwareRemoteEnvelope_fieldAccessorTable; private static akka.protobuf.Descriptors.Descriptor - internal_static_RemoteTraceContext_descriptor; + internal_static_RemoteTraceContext_descriptor; private static - akka.protobuf.GeneratedMessage.FieldAccessorTable + akka.protobuf.GeneratedMessage.FieldAccessorTable internal_static_RemoteTraceContext_fieldAccessorTable; public static akka.protobuf.Descriptors.FileDescriptor - getDescriptor() { + getDescriptor() { return descriptor; } private static akka.protobuf.Descriptors.FileDescriptor descriptor; static { java.lang.String[] descriptorData = { - "\n\"ContextAwareWireFormats.proto\032\026Co" + - "ntainerFormats.proto\032\021WireFormats.proto\"" + - "\201\001\n(AckAndTraceContextAwareEnvelopeConta" + - "iner\022!\n\003ack\030\001 \001(\0132\024.AcknowledgementInfo\022" + - "2\n\010envelope\030\002 \001(\0132 .TraceContextAwareRem" + - "oteEnvelope\"\277\001\n\037TraceContextAwareRemoteE" + - "nvelope\022 \n\trecipient\030\001 \002(\0132\r.ActorRefDat" + - "a\022#\n\007message\030\002 \002(\0132\022.SerializedMessage\022\035" + - "\n\006sender\030\004 \001(\0132\r.ActorRefData\022\013\n\003seq\030\005 \001" + - "(\006\022)\n\014traceContext\030\017 \001(\0132\023.RemoteTraceCo", - "ntext\"%\n\022RemoteTraceContext\022\017\n\007context\030\001" + - " \002(\014B\017\n\013akka.remoteH\001" + "\n\"ContextAwareWireFormats.proto\032\026Co" + + "ntainerFormats.proto\032\021WireFormats.proto\"" + + "\201\001\n(AckAndTraceContextAwareEnvelopeConta" + + "iner\022!\n\003ack\030\001 \001(\0132\024.AcknowledgementInfo\022" + + "2\n\010envelope\030\002 \001(\0132 .TraceContextAwareRem" + + "oteEnvelope\"\277\001\n\037TraceContextAwareRemoteE" + + "nvelope\022 \n\trecipient\030\001 \002(\0132\r.ActorRefDat" + + "a\022#\n\007message\030\002 \002(\0132\022.SerializedMessage\022\035" + + "\n\006sender\030\004 \001(\0132\r.ActorRefData\022\013\n\003seq\030\005 \001" + + "(\006\022)\n\014traceContext\030\017 \001(\0132\023.RemoteTraceCo", + "ntext\"%\n\022RemoteTraceContext\022\017\n\007context\030\001" + + " \002(\014B\017\n\013akka.remoteH\001" }; akka.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new akka.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public akka.protobuf.ExtensionRegistry assignDescriptors( - akka.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - internal_static_AckAndTraceContextAwareEnvelopeContainer_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_AckAndTraceContextAwareEnvelopeContainer_fieldAccessorTable = new - akka.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_AckAndTraceContextAwareEnvelopeContainer_descriptor, - new java.lang.String[] { "Ack", "Envelope", }); - internal_static_TraceContextAwareRemoteEnvelope_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_TraceContextAwareRemoteEnvelope_fieldAccessorTable = new - akka.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_TraceContextAwareRemoteEnvelope_descriptor, - new java.lang.String[] { "Recipient", "Message", "Sender", "Seq", "TraceContext", }); - internal_static_RemoteTraceContext_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_RemoteTraceContext_fieldAccessorTable = new - akka.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_RemoteTraceContext_descriptor, - new java.lang.String[] { "Context", }); - return null; - } - }; + new akka.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public akka.protobuf.ExtensionRegistry assignDescriptors( + akka.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_AckAndTraceContextAwareEnvelopeContainer_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_AckAndTraceContextAwareEnvelopeContainer_fieldAccessorTable = new + akka.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_AckAndTraceContextAwareEnvelopeContainer_descriptor, + new java.lang.String[] { "Ack", "Envelope", }); + internal_static_TraceContextAwareRemoteEnvelope_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_TraceContextAwareRemoteEnvelope_fieldAccessorTable = new + akka.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_TraceContextAwareRemoteEnvelope_descriptor, + new java.lang.String[] { "Recipient", "Message", "Sender", "Seq", "TraceContext", }); + internal_static_RemoteTraceContext_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_RemoteTraceContext_fieldAccessorTable = new + akka.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_RemoteTraceContext_descriptor, + new java.lang.String[] { "Context", }); + return null; + } + }; akka.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new akka.protobuf.Descriptors.FileDescriptor[] { - akka.remote.ContainerFormats.getDescriptor(), - akka.remote.WireFormats.getDescriptor(), - }, assigner); + .internalBuildGeneratedFileFrom(descriptorData, + new akka.protobuf.Descriptors.FileDescriptor[] { + akka.remote.ContainerFormats.getDescriptor(), + akka.remote.WireFormats.getDescriptor(), + }, assigner); } // @@protoc_insertion_point(outer_class_scope) diff --git a/kamon-akka/src/main/protobuf/ContextAwareWireFormats.proto b/instrumentation/akka-2.5/src/main/protobuf/ContextAwareWireFormats.proto similarity index 92% rename from kamon-akka/src/main/protobuf/ContextAwareWireFormats.proto rename to instrumentation/akka-2.5/src/main/protobuf/ContextAwareWireFormats.proto index 8aca487..dd493bf 100644 --- a/kamon-akka/src/main/protobuf/ContextAwareWireFormats.proto +++ b/instrumentation/akka-2.5/src/main/protobuf/ContextAwareWireFormats.proto @@ -2,7 +2,7 @@ syntax = "proto2"; import "WireFormats.proto"; -option java_package = "akka.remote.instrumentation"; +option java_package = "akka.remote"; option optimize_for = SPEED; diff --git a/kamon-akka/src/main/protobuf/WireFormats.proto b/instrumentation/akka-2.5/src/main/protobuf/WireFormats.proto similarity index 100% rename from kamon-akka/src/main/protobuf/WireFormats.proto rename to instrumentation/akka-2.5/src/main/protobuf/WireFormats.proto diff --git a/instrumentation/akka-2.5/src/main/scala-2.11/kamon/instrumentation/akka/instrumentations/akka_26/DispatcherInstrumentation.scala b/instrumentation/akka-2.5/src/main/scala-2.11/kamon/instrumentation/akka/instrumentations/akka_26/DispatcherInstrumentation.scala new file mode 100644 index 0000000..17250ad --- /dev/null +++ b/instrumentation/akka-2.5/src/main/scala-2.11/kamon/instrumentation/akka/instrumentations/akka_26/DispatcherInstrumentation.scala @@ -0,0 +1,22 @@ +/* + * ========================================================================================= + * Copyright © 2013-2018 the kamon project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + * ========================================================================================= + */ + +package kamon.instrumentation.akka.instrumentations.akka_26 + +import kanela.agent.api.instrumentation.InstrumentationBuilder + +// Only exists to avoid warnings of this class not existing when running on Scala 2.11 +class DispatcherInstrumentation extends InstrumentationBuilder {} \ No newline at end of file diff --git a/instrumentation/akka-2.5/src/main/scala-2.11/kamon/instrumentation/akka/instrumentations/akka_26/remote/RemotingInstrumentation.scala b/instrumentation/akka-2.5/src/main/scala-2.11/kamon/instrumentation/akka/instrumentations/akka_26/remote/RemotingInstrumentation.scala new file mode 100644 index 0000000..450231d --- /dev/null +++ b/instrumentation/akka-2.5/src/main/scala-2.11/kamon/instrumentation/akka/instrumentations/akka_26/remote/RemotingInstrumentation.scala @@ -0,0 +1,6 @@ +package kamon.instrumentation.akka.instrumentations.akka_26.remote + +import kanela.agent.api.instrumentation.InstrumentationBuilder + +// Only exists to avoid warnings of this class not existing when running on Scala 2.11 +class RemotingInstrumentation extends InstrumentationBuilder {} \ No newline at end of file diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/DispatcherInstrumentation.scala b/instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/DispatcherInstrumentation.scala similarity index 74% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/DispatcherInstrumentation.scala rename to instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/DispatcherInstrumentation.scala index 35b014c..8ee0a77 100644 --- a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/DispatcherInstrumentation.scala +++ b/instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/DispatcherInstrumentation.scala @@ -14,11 +14,12 @@ * ========================================================================================= */ -package kamon.instrumentation.akka.instrumentations +package kamon.instrumentation.akka.instrumentations.akka_25 import java.util.concurrent.{Callable, ExecutorService} import akka.dispatch.{DispatcherPrerequisites, ForkJoinExecutorConfigurator, PinnedDispatcherConfigurator, ThreadPoolExecutorConfigurator} +import kamon.instrumentation.akka.instrumentations.VersionFiltering import akka.dispatch.forkjoin.ForkJoinPool import kamon.Kamon import kamon.instrumentation.akka.AkkaInstrumentation @@ -51,57 +52,31 @@ class DispatcherInstrumentation extends InstrumentationBuilder with VersionFilte .intercept(method("createExecutorService"), InstrumentNewExecutorServiceOnAkka24) } - /** - * First step on getting the Actor System name is to read it from the prerequisites instance passed to the - * constructors of these two classes. - */ - onTypes("akka.dispatch.ThreadPoolExecutorConfigurator", "akka.dispatch.ForkJoinExecutorConfigurator", "akka.dispatch.PinnedDispatcherConfigurator") - .advise(isConstructor, CaptureActorSystemNameOnExecutorConfigurator) - - /** - * Copies the Actor System and Dispatcher names to the ExecutorServiceFactory instances for the two types of - * executors instrumented by Kamon. - */ - onTypes("akka.dispatch.ThreadPoolConfig", "akka.dispatch.ForkJoinExecutorConfigurator", "akka.dispatch.PinnedDispatcherConfigurator") - .mixin(classOf[HasActorSystemName.Mixin]) - .mixin(classOf[HasDispatcherName.Mixin]) - .advise(method("createExecutorServiceFactory"), CopyDispatcherInfoToExecutorServiceFactory) - - /** - * This ensures that the ActorSystem name is not lost when creating PinnedDispatcher instances. - */ - onType("akka.dispatch.ThreadPoolConfig") - .advise(method("copy"), ThreadPoolConfigCopyAdvice) - -} - -object DispatcherInfo { + onAkka("2.4", "2.5") { - trait HasActorSystemName { - def actorSystemName: String - def setActorSystemName(actorSystemName: String): Unit - } + /** + * First step on getting the Actor System name is to read it from the prerequisites instance passed to the + * constructors of these two classes. + */ + onTypes("akka.dispatch.ThreadPoolExecutorConfigurator", "akka.dispatch.ForkJoinExecutorConfigurator", "akka.dispatch.PinnedDispatcherConfigurator") + .advise(isConstructor, CaptureActorSystemNameOnExecutorConfigurator) - object HasActorSystemName { - class Mixin extends HasActorSystemName { - @volatile private var _actorSystemName: String = _ - override def actorSystemName: String = _actorSystemName - override def setActorSystemName(actorSystemName: String): Unit = _actorSystemName = actorSystemName - } - } + /** + * Copies the Actor System and Dispatcher names to the ExecutorServiceFactory instances for the two types of + * executors instrumented by Kamon. + */ + onTypes("akka.dispatch.ThreadPoolConfig", "akka.dispatch.ForkJoinExecutorConfigurator", "akka.dispatch.PinnedDispatcherConfigurator") + .mixin(classOf[HasActorSystemName.Mixin]) + .mixin(classOf[HasDispatcherName.Mixin]) + .advise(method("createExecutorServiceFactory"), CopyDispatcherInfoToExecutorServiceFactory) - trait HasDispatcherName { - def dispatcherName: String - def setDispatcherName(dispatcherName: String): Unit + /** + * This ensures that the ActorSystem name is not lost when creating PinnedDispatcher instances. + */ + onType("akka.dispatch.ThreadPoolConfig") + .advise(method("copy"), ThreadPoolConfigCopyAdvice) } - object HasDispatcherName { - class Mixin extends HasDispatcherName { - @volatile private var _dispatcherName: String = _ - override def dispatcherName: String = _dispatcherName - override def setDispatcherName(dispatcherName: String): Unit = _dispatcherName = dispatcherName - } - } } object CaptureActorSystemNameOnExecutorConfigurator { diff --git a/instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/remote/RemotingInstrumentation.scala b/instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/remote/RemotingInstrumentation.scala new file mode 100644 index 0000000..f3b2279 --- /dev/null +++ b/instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/remote/RemotingInstrumentation.scala @@ -0,0 +1,171 @@ +package kamon.instrumentation.akka.instrumentations.akka_25.remote + +import akka.actor.ActorSystem +import akka.remote.kamon.instrumentation.akka.instrumentations.akka_25.remote.{ArteryMessageDispatcherAdvice, CaptureContextOnInboundEnvelope, DeserializeForArteryAdvice, SerializeForArteryAdvice} +import akka.kamon.instrumentation.akka.instrumentations.akka_25.remote.{AkkaPduProtobufCodecConstructMessageMethodInterceptor, AkkaPduProtobufCodecDecodeMessage} +import kamon.Kamon +import kamon.context.Storage +import kamon.context.Storage.Scope +import kamon.instrumentation.akka.AkkaRemoteInstrumentation +import kamon.instrumentation.akka.AkkaRemoteMetrics.SerializationInstruments +import kamon.instrumentation.akka.instrumentations.{AkkaPrivateAccess, VersionFiltering} +import kamon.instrumentation.context.{CaptureCurrentContextOnExit, HasContext} +import kanela.agent.api.instrumentation.InstrumentationBuilder +import kanela.agent.libs.net.bytebuddy.asm.Advice + + +class RemotingInstrumentation extends InstrumentationBuilder with VersionFiltering { + + onAkka("2.4", "2.5") { + + /** + * Send messages might be buffered if they reach the EndpointWriter before it has been initialized and the current + * Context might be lost after the buffering, so we make sure we capture the context when the Send command was + * created and then apply it during the EndpointWrite.writeSend method execution (see bellow). + */ + onType("akka.remote.EndpointManager$Send") + .mixin(classOf[HasContext.Mixin]) + .advise(isConstructor, CaptureCurrentContextOnExit) + + onType("akka.remote.EndpointWriter") + .advise(method("writeSend"), WriteSendWithContext) + + /** + * Reads and writes the Akka PDU using a modified version of the Protobuf that has an extra field for a Context + * instance. + */ + onType("akka.remote.transport.AkkaPduProtobufCodec$") + .intercept(method("constructMessage"), new AkkaPduProtobufCodecConstructMessageMethodInterceptor()) + .advise(method("decodeMessage"), classOf[AkkaPduProtobufCodecDecodeMessage]) + + /** + * Mixin Serialization Instruments to the Actor System and use them to record the serialization and deserialization + * time metrics. + */ + onType("akka.actor.ActorSystemImpl") + .mixin(classOf[HasSerializationInstruments.Mixin]) + .advise(isConstructor, InitializeActorSystemAdvice) + + onType("akka.remote.MessageSerializer$") + .advise(method("serialize"), MeasureSerializationTime) + .advise(method("deserialize"), MeasureDeserializationTime) + + /** + * Artery + */ + onType("akka.remote.artery.ReusableOutboundEnvelope") + .mixin(classOf[HasContext.Mixin]) + .advise(method("copy"), CopyContextOnReusableEnvelope) + + onType("akka.remote.artery.Association") + .advise(method("createOutboundEnvelope$1"), CaptureCurrentContextOnReusableEnvelope) + + onType("akka.remote.MessageSerializer$") + .advise(method("serializeForArtery"), classOf[SerializeForArteryAdvice]) + .advise(method("deserializeForArtery"), classOf[DeserializeForArteryAdvice]) + + onType("akka.remote.artery.ReusableInboundEnvelope") + .mixin(classOf[HasContext.Mixin]) + .advise(method("withMessage"), classOf[CaptureContextOnInboundEnvelope]) + .advise(method("copyForLane"), CopyContextOnReusableEnvelope) + + onType("akka.remote.artery.MessageDispatcher") + .advise(method("dispatch"), classOf[ArteryMessageDispatcherAdvice]) + } + +} + + +object CopyContextOnReusableEnvelope { + + @Advice.OnMethodExit + def exit(@Advice.This oldEnvelope: Any, @Advice.Return newEnvelope: Any): Unit = + newEnvelope.asInstanceOf[HasContext].setContext(oldEnvelope.asInstanceOf[HasContext].context) +} + +object CaptureCurrentContextOnReusableEnvelope { + + @Advice.OnMethodExit + def exit(@Advice.Return envelope: Any): Unit = { + envelope.asInstanceOf[HasContext].setContext(Kamon.currentContext()) + } +} + +object WriteSendWithContext { + + @Advice.OnMethodEnter + def enter(@Advice.Argument(0) send: Any): Scope = { + Kamon.storeContext(send.asInstanceOf[HasContext].context) + } + + @Advice.OnMethodExit + def exit(@Advice.Enter scope: Scope): Unit = { + scope.asInstanceOf[Scope].close() + } +} + +trait HasSerializationInstruments { + def serializationInstruments: SerializationInstruments + def setSerializationInstruments(instruments: SerializationInstruments): Unit +} + +object HasSerializationInstruments { + + class Mixin(var serializationInstruments: SerializationInstruments) extends HasSerializationInstruments { + override def setSerializationInstruments(instruments: SerializationInstruments): Unit = + serializationInstruments = instruments + } +} + +object InitializeActorSystemAdvice { + + @Advice.OnMethodExit + def exit(@Advice.This system: ActorSystem with HasSerializationInstruments): Unit = + system.setSerializationInstruments(new SerializationInstruments(system.name)) + +} + +object MeasureSerializationTime { + + @Advice.OnMethodEnter + def enter(): Long = { + if(AkkaRemoteInstrumentation.settings().trackSerializationMetrics) System.nanoTime() else 0L + } + + @Advice.OnMethodExit + def exit(@Advice.Argument(0) system: AnyRef, @Advice.Enter startNanoTime: Long): Unit = { + if(startNanoTime != 0L) { + system.asInstanceOf[HasSerializationInstruments] + .serializationInstruments + .serializationTime + .record(System.nanoTime() - startNanoTime) + } + } +} + +object MeasureDeserializationTime { + + @Advice.OnMethodEnter + def enter(): Long = { + if(AkkaRemoteInstrumentation.settings().trackSerializationMetrics) System.nanoTime() else 0L + } + + @Advice.OnMethodExit + def exit(@Advice.Argument(0) system: AnyRef, @Advice.Enter startNanoTime: Long, @Advice.Return msg: Any): Unit = { + + if(AkkaPrivateAccess.isSystemMessage(msg)) { + msg match { + case hc: HasContext if hc.context == null => + hc.setContext(Kamon.currentContext()) + case _ => + } + } + + if(startNanoTime != 0L) { + system.asInstanceOf[HasSerializationInstruments] + .serializationInstruments + .deserializationTime + .record(System.nanoTime() - startNanoTime) + } + } +} diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/internal/AkkaPduProtobufCodecConstructMessageMethodInterceptor.scala b/instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/remote/internal/AkkaPduProtobufCodecConstructMessageMethodInterceptor.scala similarity index 98% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/internal/AkkaPduProtobufCodecConstructMessageMethodInterceptor.scala rename to instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/remote/internal/AkkaPduProtobufCodecConstructMessageMethodInterceptor.scala index c1b2b01..012e959 100644 --- a/kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/internal/AkkaPduProtobufCodecConstructMessageMethodInterceptor.scala +++ b/instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/remote/internal/AkkaPduProtobufCodecConstructMessageMethodInterceptor.scala @@ -1,4 +1,4 @@ -package akka.kamon.instrumentation.kanela.interceptor +package akka.kamon.instrumentation.akka.instrumentations.akka_25.remote import java.io.ByteArrayOutputStream diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/internal/AkkaPduProtobufCodecDecodeMessageMethodAdvisor.scala b/instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/remote/internal/AkkaPduProtobufCodecDecodeMessageMethodAdvisor.scala similarity index 87% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/internal/AkkaPduProtobufCodecDecodeMessageMethodAdvisor.scala rename to instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/remote/internal/AkkaPduProtobufCodecDecodeMessageMethodAdvisor.scala index ec909d8..3ff4c00 100644 --- a/kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/internal/AkkaPduProtobufCodecDecodeMessageMethodAdvisor.scala +++ b/instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/remote/internal/AkkaPduProtobufCodecDecodeMessageMethodAdvisor.scala @@ -1,18 +1,19 @@ -package akka.remote.kamon.instrumentation.kanela.advisor +package akka.kamon.instrumentation.akka.instrumentations.akka_25.remote -import akka.actor.{Address} -import akka.remote.ContextAwareWireFormats.AckAndContextAwareEnvelopeContainer +import akka.actor.Address import akka.remote.RemoteActorRefProvider import akka.util.ByteString import kamon.Kamon import kamon.context.BinaryPropagation.ByteStreamReader import kamon.instrumentation.akka.AkkaRemoteMetrics import kanela.agent.libs.net.bytebuddy.asm.Advice.{Argument, OnMethodEnter} +import akka.remote.ContextAwareWireFormats.{AckAndContextAwareEnvelopeContainer} /** * Advisor for akka.remote.transport.AkkaPduProtobufCodec$::decodeMessage */ class AkkaPduProtobufCodecDecodeMessage + object AkkaPduProtobufCodecDecodeMessage { @OnMethodEnter diff --git a/instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/remote/internal/ArterySerializationAdvice.scala b/instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/remote/internal/ArterySerializationAdvice.scala new file mode 100644 index 0000000..02ec969 --- /dev/null +++ b/instrumentation/akka-2.5/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_25/remote/internal/ArterySerializationAdvice.scala @@ -0,0 +1,171 @@ +package akka.remote.kamon.instrumentation.akka.instrumentations.akka_25.remote + +import java.nio.ByteBuffer + +import akka.actor.ActorSystem +import akka.dispatch.sysmsg.SystemMessage +import akka.remote.artery.{EnvelopeBuffer, InboundEnvelope, OutboundEnvelope} +import akka.serialization.Serialization +import kamon.Kamon +import kamon.context.{BinaryPropagation, Context, Storage} +import kamon.instrumentation.akka.AkkaRemoteMetrics +import kamon.instrumentation.context.HasContext +import kanela.agent.libs.net.bytebuddy.asm.Advice + + +/** + * For Artery messages we will always add two sections to the end of each serialized message: the Context and the size + * of the Context. The layout will look something like this: + * + * |------------------ Actual Message ------------------||-- Kamon Context --||-- Context Size (4 bytes) --| + * + * If the Context is empty the Context size will be zero. + */ + +class SerializeForArteryAdvice +object SerializeForArteryAdvice { + + @Advice.OnMethodEnter + def enter(): Long = { + System.nanoTime() + } + + @Advice.OnMethodExit + def exit(@Advice.Argument(0) serialization: Serialization, @Advice.Argument(1) envelope: OutboundEnvelope, + @Advice.Argument(3) envelopeBuffer: EnvelopeBuffer, @Advice.Enter startTime: Long): Unit = { + + val instruments = AkkaRemoteMetrics.serializationInstruments(serialization.system.name) + val messageBuffer = envelopeBuffer.byteBuffer + val context = envelope.asInstanceOf[HasContext].context + val positionBeforeContext = messageBuffer.position() + + if(context.nonEmpty()) { + Kamon.defaultBinaryPropagation().write(context, byteBufferWriter(messageBuffer)) + } + + instruments.serializationTime.record(System.nanoTime() - startTime) + instruments.outboundMessageSize.record(positionBeforeContext) + + val contextSize = messageBuffer.position() - positionBeforeContext + messageBuffer.putInt(contextSize) + } + + def byteBufferWriter(bb: ByteBuffer): BinaryPropagation.ByteStreamWriter = new BinaryPropagation.ByteStreamWriter { + override def write(bytes: Array[Byte]): Unit = + bb.put(bytes) + + override def write(bytes: Array[Byte], offset: Int, count: Int): Unit = + bb.put(bytes, offset, count) + + override def write(byte: Int): Unit = + bb.put(byte.toByte) + } +} + +class DeserializeForArteryAdvice +object DeserializeForArteryAdvice { + + val LastDeserializedContext = new ThreadLocal[Context]() { + override def initialValue(): Context = null + } + + case class DeserializationInfo( + context: Context, + timeStamp: Long, + messageSize: Long + ) + + @Advice.OnMethodEnter + def exit(@Advice.Argument(5) envelopeBuffer: EnvelopeBuffer): DeserializationInfo = { + val startTime = System.nanoTime() + val messageBuffer = envelopeBuffer.byteBuffer + val messageStart = messageBuffer.position() + + messageBuffer.mark() + messageBuffer.position(messageBuffer.limit() - 4) + val contextSize = messageBuffer.getInt() + val contextStart = messageBuffer.limit() - (contextSize + 4) + val messageSize = contextStart - messageStart + + val context = if(contextSize == 0) + Context.Empty + else { + messageBuffer + .position(contextStart) + .limit(contextStart + contextSize) + + Kamon.defaultBinaryPropagation().read(byteBufferReader(messageBuffer)) + } + + messageBuffer.reset() + messageBuffer.limit(contextStart) + DeserializationInfo(context, startTime, messageSize) + } + + @Advice.OnMethodExit(onThrowable = classOf[Throwable]) + def exit(@Advice.Argument(0) system: ActorSystem, @Advice.Argument(5) envelopeBuffer: EnvelopeBuffer, + @Advice.Enter deserializationInfo: DeserializationInfo, @Advice.Thrown error: Throwable): Unit = { + + if(error == null) { + LastDeserializedContext.set(deserializationInfo.context) + + val instruments = AkkaRemoteMetrics.serializationInstruments(system.name) + instruments.deserializationTime.record(System.nanoTime() - deserializationInfo.timeStamp) + instruments.inboundMessageSize.record(deserializationInfo.messageSize) + } + } + + + def byteBufferReader(bb: ByteBuffer): BinaryPropagation.ByteStreamReader = new BinaryPropagation.ByteStreamReader { + override def available(): Int = + bb.remaining() + + override def read(target: Array[Byte]): Int = { + bb.get(target) + target.length + } + + override def read(target: Array[Byte], offset: Int, count: Int): Int = { + bb.get(target, offset, count) + target.length + } + + override def readAll(): Array[Byte] = { + val array = Array.ofDim[Byte](bb.remaining()) + bb.get(array) + array + } + } +} + +class CaptureContextOnInboundEnvelope +object CaptureContextOnInboundEnvelope { + + @Advice.OnMethodEnter + def enter(@Advice.This inboundEnvelope: Any): Unit = { + val lastContext = DeserializeForArteryAdvice.LastDeserializedContext.get() + if(lastContext != null) { + inboundEnvelope.asInstanceOf[HasContext].setContext(lastContext) + DeserializeForArteryAdvice.LastDeserializedContext.set(null) + } + } + +} + +class ArteryMessageDispatcherAdvice +object ArteryMessageDispatcherAdvice { + + @Advice.OnMethodEnter + def enter(@Advice.Argument(0) envelope: InboundEnvelope): Storage.Scope = { + val context = envelope.asInstanceOf[HasContext].context + if(envelope.message.isInstanceOf[SystemMessage]) { + envelope.message.asInstanceOf[HasContext].setContext(context) + } + + Kamon.storeContext(envelope.asInstanceOf[HasContext].context) + } + + @Advice.OnMethodExit + def exit(@Advice.Enter scope: Storage.Scope): Unit = + scope.close() +} \ No newline at end of file diff --git a/instrumentation/akka-2.6/src/main/java/akka/remote/ContextAwareWireFormats_Akka26.java b/instrumentation/akka-2.6/src/main/java/akka/remote/ContextAwareWireFormats_Akka26.java new file mode 100644 index 0000000..2c967ef --- /dev/null +++ b/instrumentation/akka-2.6/src/main/java/akka/remote/ContextAwareWireFormats_Akka26.java @@ -0,0 +1,2802 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ContextAwareWireFormats_Akka26.proto + +package akka.remote; + +public final class ContextAwareWireFormats_Akka26 { + private ContextAwareWireFormats_Akka26() {} + public static void registerAllExtensions( + akka.protobufv3.internal.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + akka.protobufv3.internal.ExtensionRegistry registry) { + registerAllExtensions( + (akka.protobufv3.internal.ExtensionRegistryLite) registry); + } + public interface AckAndContextAwareEnvelopeContainerOrBuilder extends + // @@protoc_insertion_point(interface_extends:AckAndContextAwareEnvelopeContainer) + akka.protobufv3.internal.MessageOrBuilder { + + /** + * optional .AcknowledgementInfo ack = 1; + */ + boolean hasAck(); + /** + * optional .AcknowledgementInfo ack = 1; + */ + akka.remote.WireFormats.AcknowledgementInfo getAck(); + /** + * optional .AcknowledgementInfo ack = 1; + */ + akka.remote.WireFormats.AcknowledgementInfoOrBuilder getAckOrBuilder(); + + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + boolean hasEnvelope(); + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope getEnvelope(); + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelopeOrBuilder getEnvelopeOrBuilder(); + } + /** + * Protobuf type {@code AckAndContextAwareEnvelopeContainer} + */ + public static final class AckAndContextAwareEnvelopeContainer extends + akka.protobufv3.internal.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:AckAndContextAwareEnvelopeContainer) + AckAndContextAwareEnvelopeContainerOrBuilder { + private static final long serialVersionUID = 0L; + // Use AckAndContextAwareEnvelopeContainer.newBuilder() to construct. + private AckAndContextAwareEnvelopeContainer(akka.protobufv3.internal.GeneratedMessageV3.Builder builder) { + super(builder); + } + private AckAndContextAwareEnvelopeContainer() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new AckAndContextAwareEnvelopeContainer(); + } + + @java.lang.Override + public final akka.protobufv3.internal.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AckAndContextAwareEnvelopeContainer( + akka.protobufv3.internal.CodedInputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + akka.protobufv3.internal.UnknownFieldSet.Builder unknownFields = + akka.protobufv3.internal.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + akka.remote.WireFormats.AcknowledgementInfo.Builder subBuilder = null; + if (((bitField0_ & 0x00000001) != 0)) { + subBuilder = ack_.toBuilder(); + } + ack_ = input.readMessage(akka.remote.WireFormats.AcknowledgementInfo.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(ack_); + ack_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000001; + break; + } + case 18: { + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.Builder subBuilder = null; + if (((bitField0_ & 0x00000002) != 0)) { + subBuilder = envelope_.toBuilder(); + } + envelope_ = input.readMessage(ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(envelope_); + envelope_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000002; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (akka.protobufv3.internal.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new akka.protobufv3.internal.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final akka.protobufv3.internal.Descriptors.Descriptor + getDescriptor() { + return ContextAwareWireFormats_Akka26.internal_static_AckAndContextAwareEnvelopeContainer_descriptor; + } + + @java.lang.Override + protected akka.protobufv3.internal.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return ContextAwareWireFormats_Akka26.internal_static_AckAndContextAwareEnvelopeContainer_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer.class, ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer.Builder.class); + } + + private int bitField0_; + public static final int ACK_FIELD_NUMBER = 1; + private akka.remote.WireFormats.AcknowledgementInfo ack_; + /** + * optional .AcknowledgementInfo ack = 1; + */ + public boolean hasAck() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * optional .AcknowledgementInfo ack = 1; + */ + public akka.remote.WireFormats.AcknowledgementInfo getAck() { + return ack_ == null ? akka.remote.WireFormats.AcknowledgementInfo.getDefaultInstance() : ack_; + } + /** + * optional .AcknowledgementInfo ack = 1; + */ + public akka.remote.WireFormats.AcknowledgementInfoOrBuilder getAckOrBuilder() { + return ack_ == null ? akka.remote.WireFormats.AcknowledgementInfo.getDefaultInstance() : ack_; + } + + public static final int ENVELOPE_FIELD_NUMBER = 2; + private ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope envelope_; + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + public boolean hasEnvelope() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + public ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope getEnvelope() { + return envelope_ == null ? ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.getDefaultInstance() : envelope_; + } + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + public ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelopeOrBuilder getEnvelopeOrBuilder() { + return envelope_ == null ? ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.getDefaultInstance() : envelope_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + if (hasAck()) { + if (!getAck().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + if (hasEnvelope()) { + if (!getEnvelope().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(akka.protobufv3.internal.CodedOutputStream output) + throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getAck()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getEnvelope()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += akka.protobufv3.internal.CodedOutputStream + .computeMessageSize(1, getAck()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += akka.protobufv3.internal.CodedOutputStream + .computeMessageSize(2, getEnvelope()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer)) { + return super.equals(obj); + } + ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer other = (ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer) obj; + + if (hasAck() != other.hasAck()) return false; + if (hasAck()) { + if (!getAck() + .equals(other.getAck())) return false; + } + if (hasEnvelope() != other.hasEnvelope()) return false; + if (hasEnvelope()) { + if (!getEnvelope() + .equals(other.getEnvelope())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasAck()) { + hash = (37 * hash) + ACK_FIELD_NUMBER; + hash = (53 * hash) + getAck().hashCode(); + } + if (hasEnvelope()) { + hash = (37 * hash) + ENVELOPE_FIELD_NUMBER; + hash = (53 * hash) + getEnvelope().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer parseFrom( + java.nio.ByteBuffer data) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer parseFrom( + java.nio.ByteBuffer data, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer parseFrom( + akka.protobufv3.internal.ByteString data) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer parseFrom( + akka.protobufv3.internal.ByteString data, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer parseFrom(byte[] data) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer parseFrom( + byte[] data, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer parseFrom(java.io.InputStream input) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer parseFrom( + java.io.InputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer parseDelimitedFrom( + java.io.InputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer parseFrom( + akka.protobufv3.internal.CodedInputStream input) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer parseFrom( + akka.protobufv3.internal.CodedInputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + akka.protobufv3.internal.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code AckAndContextAwareEnvelopeContainer} + */ + public static final class Builder extends + akka.protobufv3.internal.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:AckAndContextAwareEnvelopeContainer) + ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainerOrBuilder { + public static final akka.protobufv3.internal.Descriptors.Descriptor + getDescriptor() { + return ContextAwareWireFormats_Akka26.internal_static_AckAndContextAwareEnvelopeContainer_descriptor; + } + + @java.lang.Override + protected akka.protobufv3.internal.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return ContextAwareWireFormats_Akka26.internal_static_AckAndContextAwareEnvelopeContainer_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer.class, ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer.Builder.class); + } + + // Construct using akka.remote.ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + akka.protobufv3.internal.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (akka.protobufv3.internal.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getAckFieldBuilder(); + getEnvelopeFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (ackBuilder_ == null) { + ack_ = null; + } else { + ackBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + if (envelopeBuilder_ == null) { + envelope_ = null; + } else { + envelopeBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + @java.lang.Override + public akka.protobufv3.internal.Descriptors.Descriptor + getDescriptorForType() { + return ContextAwareWireFormats_Akka26.internal_static_AckAndContextAwareEnvelopeContainer_descriptor; + } + + @java.lang.Override + public ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer getDefaultInstanceForType() { + return ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer.getDefaultInstance(); + } + + @java.lang.Override + public ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer build() { + ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer buildPartial() { + ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer result = new ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + if (ackBuilder_ == null) { + result.ack_ = ack_; + } else { + result.ack_ = ackBuilder_.build(); + } + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + if (envelopeBuilder_ == null) { + result.envelope_ = envelope_; + } else { + result.envelope_ = envelopeBuilder_.build(); + } + to_bitField0_ |= 0x00000002; + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + akka.protobufv3.internal.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + akka.protobufv3.internal.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + akka.protobufv3.internal.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + akka.protobufv3.internal.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + akka.protobufv3.internal.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(akka.protobufv3.internal.Message other) { + if (other instanceof ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer) { + return mergeFrom((ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer other) { + if (other == ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer.getDefaultInstance()) return this; + if (other.hasAck()) { + mergeAck(other.getAck()); + } + if (other.hasEnvelope()) { + mergeEnvelope(other.getEnvelope()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + if (hasAck()) { + if (!getAck().isInitialized()) { + return false; + } + } + if (hasEnvelope()) { + if (!getEnvelope().isInitialized()) { + return false; + } + } + return true; + } + + @java.lang.Override + public Builder mergeFrom( + akka.protobufv3.internal.CodedInputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (akka.protobufv3.internal.InvalidProtocolBufferException e) { + parsedMessage = (ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private akka.remote.WireFormats.AcknowledgementInfo ack_; + private akka.protobufv3.internal.SingleFieldBuilderV3< + akka.remote.WireFormats.AcknowledgementInfo, akka.remote.WireFormats.AcknowledgementInfo.Builder, akka.remote.WireFormats.AcknowledgementInfoOrBuilder> ackBuilder_; + /** + * optional .AcknowledgementInfo ack = 1; + */ + public boolean hasAck() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * optional .AcknowledgementInfo ack = 1; + */ + public akka.remote.WireFormats.AcknowledgementInfo getAck() { + if (ackBuilder_ == null) { + return ack_ == null ? akka.remote.WireFormats.AcknowledgementInfo.getDefaultInstance() : ack_; + } else { + return ackBuilder_.getMessage(); + } + } + /** + * optional .AcknowledgementInfo ack = 1; + */ + public Builder setAck(akka.remote.WireFormats.AcknowledgementInfo value) { + if (ackBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ack_ = value; + onChanged(); + } else { + ackBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * optional .AcknowledgementInfo ack = 1; + */ + public Builder setAck( + akka.remote.WireFormats.AcknowledgementInfo.Builder builderForValue) { + if (ackBuilder_ == null) { + ack_ = builderForValue.build(); + onChanged(); + } else { + ackBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * optional .AcknowledgementInfo ack = 1; + */ + public Builder mergeAck(akka.remote.WireFormats.AcknowledgementInfo value) { + if (ackBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) && + ack_ != null && + ack_ != akka.remote.WireFormats.AcknowledgementInfo.getDefaultInstance()) { + ack_ = + akka.remote.WireFormats.AcknowledgementInfo.newBuilder(ack_).mergeFrom(value).buildPartial(); + } else { + ack_ = value; + } + onChanged(); + } else { + ackBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * optional .AcknowledgementInfo ack = 1; + */ + public Builder clearAck() { + if (ackBuilder_ == null) { + ack_ = null; + onChanged(); + } else { + ackBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + /** + * optional .AcknowledgementInfo ack = 1; + */ + public akka.remote.WireFormats.AcknowledgementInfo.Builder getAckBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getAckFieldBuilder().getBuilder(); + } + /** + * optional .AcknowledgementInfo ack = 1; + */ + public akka.remote.WireFormats.AcknowledgementInfoOrBuilder getAckOrBuilder() { + if (ackBuilder_ != null) { + return ackBuilder_.getMessageOrBuilder(); + } else { + return ack_ == null ? + akka.remote.WireFormats.AcknowledgementInfo.getDefaultInstance() : ack_; + } + } + /** + * optional .AcknowledgementInfo ack = 1; + */ + private akka.protobufv3.internal.SingleFieldBuilderV3< + akka.remote.WireFormats.AcknowledgementInfo, akka.remote.WireFormats.AcknowledgementInfo.Builder, akka.remote.WireFormats.AcknowledgementInfoOrBuilder> + getAckFieldBuilder() { + if (ackBuilder_ == null) { + ackBuilder_ = new akka.protobufv3.internal.SingleFieldBuilderV3< + akka.remote.WireFormats.AcknowledgementInfo, akka.remote.WireFormats.AcknowledgementInfo.Builder, akka.remote.WireFormats.AcknowledgementInfoOrBuilder>( + getAck(), + getParentForChildren(), + isClean()); + ack_ = null; + } + return ackBuilder_; + } + + private ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope envelope_; + private akka.protobufv3.internal.SingleFieldBuilderV3< + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope, ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.Builder, ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelopeOrBuilder> envelopeBuilder_; + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + public boolean hasEnvelope() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + public ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope getEnvelope() { + if (envelopeBuilder_ == null) { + return envelope_ == null ? ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.getDefaultInstance() : envelope_; + } else { + return envelopeBuilder_.getMessage(); + } + } + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + public Builder setEnvelope(ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope value) { + if (envelopeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + envelope_ = value; + onChanged(); + } else { + envelopeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + public Builder setEnvelope( + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.Builder builderForValue) { + if (envelopeBuilder_ == null) { + envelope_ = builderForValue.build(); + onChanged(); + } else { + envelopeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + public Builder mergeEnvelope(ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope value) { + if (envelopeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) && + envelope_ != null && + envelope_ != ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.getDefaultInstance()) { + envelope_ = + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.newBuilder(envelope_).mergeFrom(value).buildPartial(); + } else { + envelope_ = value; + } + onChanged(); + } else { + envelopeBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + public Builder clearEnvelope() { + if (envelopeBuilder_ == null) { + envelope_ = null; + onChanged(); + } else { + envelopeBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + public ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.Builder getEnvelopeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getEnvelopeFieldBuilder().getBuilder(); + } + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + public ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelopeOrBuilder getEnvelopeOrBuilder() { + if (envelopeBuilder_ != null) { + return envelopeBuilder_.getMessageOrBuilder(); + } else { + return envelope_ == null ? + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.getDefaultInstance() : envelope_; + } + } + /** + * optional .ContextAwareRemoteEnvelope envelope = 2; + */ + private akka.protobufv3.internal.SingleFieldBuilderV3< + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope, ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.Builder, ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelopeOrBuilder> + getEnvelopeFieldBuilder() { + if (envelopeBuilder_ == null) { + envelopeBuilder_ = new akka.protobufv3.internal.SingleFieldBuilderV3< + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope, ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.Builder, ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelopeOrBuilder>( + getEnvelope(), + getParentForChildren(), + isClean()); + envelope_ = null; + } + return envelopeBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final akka.protobufv3.internal.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final akka.protobufv3.internal.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:AckAndContextAwareEnvelopeContainer) + } + + // @@protoc_insertion_point(class_scope:AckAndContextAwareEnvelopeContainer) + private static final ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer(); + } + + public static ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + @java.lang.Deprecated public static final akka.protobufv3.internal.Parser + PARSER = new akka.protobufv3.internal.AbstractParser() { + @java.lang.Override + public AckAndContextAwareEnvelopeContainer parsePartialFrom( + akka.protobufv3.internal.CodedInputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return new AckAndContextAwareEnvelopeContainer(input, extensionRegistry); + } + }; + + public static akka.protobufv3.internal.Parser parser() { + return PARSER; + } + + @java.lang.Override + public akka.protobufv3.internal.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ContextAwareRemoteEnvelopeOrBuilder extends + // @@protoc_insertion_point(interface_extends:ContextAwareRemoteEnvelope) + akka.protobufv3.internal.MessageOrBuilder { + + /** + * required .ActorRefData recipient = 1; + */ + boolean hasRecipient(); + /** + * required .ActorRefData recipient = 1; + */ + akka.remote.WireFormats.ActorRefData getRecipient(); + /** + * required .ActorRefData recipient = 1; + */ + akka.remote.WireFormats.ActorRefDataOrBuilder getRecipientOrBuilder(); + + /** + * required .SerializedMessage message = 2; + */ + boolean hasMessage(); + /** + * required .SerializedMessage message = 2; + */ + akka.remote.WireFormats.SerializedMessage getMessage(); + /** + * required .SerializedMessage message = 2; + */ + akka.remote.WireFormats.SerializedMessageOrBuilder getMessageOrBuilder(); + + /** + * optional .ActorRefData sender = 4; + */ + boolean hasSender(); + /** + * optional .ActorRefData sender = 4; + */ + akka.remote.WireFormats.ActorRefData getSender(); + /** + * optional .ActorRefData sender = 4; + */ + akka.remote.WireFormats.ActorRefDataOrBuilder getSenderOrBuilder(); + + /** + * optional fixed64 seq = 5; + */ + boolean hasSeq(); + /** + * optional fixed64 seq = 5; + */ + long getSeq(); + + /** + * optional .RemoteContext traceContext = 15; + */ + boolean hasTraceContext(); + /** + * optional .RemoteContext traceContext = 15; + */ + ContextAwareWireFormats_Akka26.RemoteContext getTraceContext(); + /** + * optional .RemoteContext traceContext = 15; + */ + ContextAwareWireFormats_Akka26.RemoteContextOrBuilder getTraceContextOrBuilder(); + } + /** + * Protobuf type {@code ContextAwareRemoteEnvelope} + */ + public static final class ContextAwareRemoteEnvelope extends + akka.protobufv3.internal.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:ContextAwareRemoteEnvelope) + ContextAwareRemoteEnvelopeOrBuilder { + private static final long serialVersionUID = 0L; + // Use ContextAwareRemoteEnvelope.newBuilder() to construct. + private ContextAwareRemoteEnvelope(akka.protobufv3.internal.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ContextAwareRemoteEnvelope() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ContextAwareRemoteEnvelope(); + } + + @java.lang.Override + public final akka.protobufv3.internal.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ContextAwareRemoteEnvelope( + akka.protobufv3.internal.CodedInputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + akka.protobufv3.internal.UnknownFieldSet.Builder unknownFields = + akka.protobufv3.internal.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + akka.remote.WireFormats.ActorRefData.Builder subBuilder = null; + if (((bitField0_ & 0x00000001) != 0)) { + subBuilder = recipient_.toBuilder(); + } + recipient_ = input.readMessage(akka.remote.WireFormats.ActorRefData.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(recipient_); + recipient_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000001; + break; + } + case 18: { + akka.remote.WireFormats.SerializedMessage.Builder subBuilder = null; + if (((bitField0_ & 0x00000002) != 0)) { + subBuilder = message_.toBuilder(); + } + message_ = input.readMessage(akka.remote.WireFormats.SerializedMessage.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(message_); + message_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000002; + break; + } + case 34: { + akka.remote.WireFormats.ActorRefData.Builder subBuilder = null; + if (((bitField0_ & 0x00000004) != 0)) { + subBuilder = sender_.toBuilder(); + } + sender_ = input.readMessage(akka.remote.WireFormats.ActorRefData.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(sender_); + sender_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000004; + break; + } + case 41: { + bitField0_ |= 0x00000008; + seq_ = input.readFixed64(); + break; + } + case 122: { + ContextAwareWireFormats_Akka26.RemoteContext.Builder subBuilder = null; + if (((bitField0_ & 0x00000010) != 0)) { + subBuilder = traceContext_.toBuilder(); + } + traceContext_ = input.readMessage(ContextAwareWireFormats_Akka26.RemoteContext.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(traceContext_); + traceContext_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000010; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (akka.protobufv3.internal.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new akka.protobufv3.internal.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final akka.protobufv3.internal.Descriptors.Descriptor + getDescriptor() { + return ContextAwareWireFormats_Akka26.internal_static_ContextAwareRemoteEnvelope_descriptor; + } + + @java.lang.Override + protected akka.protobufv3.internal.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return ContextAwareWireFormats_Akka26.internal_static_ContextAwareRemoteEnvelope_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.class, ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.Builder.class); + } + + private int bitField0_; + public static final int RECIPIENT_FIELD_NUMBER = 1; + private akka.remote.WireFormats.ActorRefData recipient_; + /** + * required .ActorRefData recipient = 1; + */ + public boolean hasRecipient() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * required .ActorRefData recipient = 1; + */ + public akka.remote.WireFormats.ActorRefData getRecipient() { + return recipient_ == null ? akka.remote.WireFormats.ActorRefData.getDefaultInstance() : recipient_; + } + /** + * required .ActorRefData recipient = 1; + */ + public akka.remote.WireFormats.ActorRefDataOrBuilder getRecipientOrBuilder() { + return recipient_ == null ? akka.remote.WireFormats.ActorRefData.getDefaultInstance() : recipient_; + } + + public static final int MESSAGE_FIELD_NUMBER = 2; + private akka.remote.WireFormats.SerializedMessage message_; + /** + * required .SerializedMessage message = 2; + */ + public boolean hasMessage() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * required .SerializedMessage message = 2; + */ + public akka.remote.WireFormats.SerializedMessage getMessage() { + return message_ == null ? akka.remote.WireFormats.SerializedMessage.getDefaultInstance() : message_; + } + /** + * required .SerializedMessage message = 2; + */ + public akka.remote.WireFormats.SerializedMessageOrBuilder getMessageOrBuilder() { + return message_ == null ? akka.remote.WireFormats.SerializedMessage.getDefaultInstance() : message_; + } + + public static final int SENDER_FIELD_NUMBER = 4; + private akka.remote.WireFormats.ActorRefData sender_; + /** + * optional .ActorRefData sender = 4; + */ + public boolean hasSender() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * optional .ActorRefData sender = 4; + */ + public akka.remote.WireFormats.ActorRefData getSender() { + return sender_ == null ? akka.remote.WireFormats.ActorRefData.getDefaultInstance() : sender_; + } + /** + * optional .ActorRefData sender = 4; + */ + public akka.remote.WireFormats.ActorRefDataOrBuilder getSenderOrBuilder() { + return sender_ == null ? akka.remote.WireFormats.ActorRefData.getDefaultInstance() : sender_; + } + + public static final int SEQ_FIELD_NUMBER = 5; + private long seq_; + /** + * optional fixed64 seq = 5; + */ + public boolean hasSeq() { + return ((bitField0_ & 0x00000008) != 0); + } + /** + * optional fixed64 seq = 5; + */ + public long getSeq() { + return seq_; + } + + public static final int TRACECONTEXT_FIELD_NUMBER = 15; + private ContextAwareWireFormats_Akka26.RemoteContext traceContext_; + /** + * optional .RemoteContext traceContext = 15; + */ + public boolean hasTraceContext() { + return ((bitField0_ & 0x00000010) != 0); + } + /** + * optional .RemoteContext traceContext = 15; + */ + public ContextAwareWireFormats_Akka26.RemoteContext getTraceContext() { + return traceContext_ == null ? ContextAwareWireFormats_Akka26.RemoteContext.getDefaultInstance() : traceContext_; + } + /** + * optional .RemoteContext traceContext = 15; + */ + public ContextAwareWireFormats_Akka26.RemoteContextOrBuilder getTraceContextOrBuilder() { + return traceContext_ == null ? ContextAwareWireFormats_Akka26.RemoteContext.getDefaultInstance() : traceContext_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + if (!hasRecipient()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasMessage()) { + memoizedIsInitialized = 0; + return false; + } + if (!getRecipient().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + if (!getMessage().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + if (hasSender()) { + if (!getSender().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + if (hasTraceContext()) { + if (!getTraceContext().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(akka.protobufv3.internal.CodedOutputStream output) + throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getRecipient()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getMessage()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(4, getSender()); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeFixed64(5, seq_); + } + if (((bitField0_ & 0x00000010) != 0)) { + output.writeMessage(15, getTraceContext()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += akka.protobufv3.internal.CodedOutputStream + .computeMessageSize(1, getRecipient()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += akka.protobufv3.internal.CodedOutputStream + .computeMessageSize(2, getMessage()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += akka.protobufv3.internal.CodedOutputStream + .computeMessageSize(4, getSender()); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += akka.protobufv3.internal.CodedOutputStream + .computeFixed64Size(5, seq_); + } + if (((bitField0_ & 0x00000010) != 0)) { + size += akka.protobufv3.internal.CodedOutputStream + .computeMessageSize(15, getTraceContext()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope)) { + return super.equals(obj); + } + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope other = (ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope) obj; + + if (hasRecipient() != other.hasRecipient()) return false; + if (hasRecipient()) { + if (!getRecipient() + .equals(other.getRecipient())) return false; + } + if (hasMessage() != other.hasMessage()) return false; + if (hasMessage()) { + if (!getMessage() + .equals(other.getMessage())) return false; + } + if (hasSender() != other.hasSender()) return false; + if (hasSender()) { + if (!getSender() + .equals(other.getSender())) return false; + } + if (hasSeq() != other.hasSeq()) return false; + if (hasSeq()) { + if (getSeq() + != other.getSeq()) return false; + } + if (hasTraceContext() != other.hasTraceContext()) return false; + if (hasTraceContext()) { + if (!getTraceContext() + .equals(other.getTraceContext())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasRecipient()) { + hash = (37 * hash) + RECIPIENT_FIELD_NUMBER; + hash = (53 * hash) + getRecipient().hashCode(); + } + if (hasMessage()) { + hash = (37 * hash) + MESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getMessage().hashCode(); + } + if (hasSender()) { + hash = (37 * hash) + SENDER_FIELD_NUMBER; + hash = (53 * hash) + getSender().hashCode(); + } + if (hasSeq()) { + hash = (37 * hash) + SEQ_FIELD_NUMBER; + hash = (53 * hash) + akka.protobufv3.internal.Internal.hashLong( + getSeq()); + } + if (hasTraceContext()) { + hash = (37 * hash) + TRACECONTEXT_FIELD_NUMBER; + hash = (53 * hash) + getTraceContext().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope parseFrom( + java.nio.ByteBuffer data) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope parseFrom( + java.nio.ByteBuffer data, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope parseFrom( + akka.protobufv3.internal.ByteString data) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope parseFrom( + akka.protobufv3.internal.ByteString data, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope parseFrom(byte[] data) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope parseFrom( + byte[] data, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope parseFrom(java.io.InputStream input) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope parseFrom( + java.io.InputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope parseDelimitedFrom( + java.io.InputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope parseFrom( + akka.protobufv3.internal.CodedInputStream input) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope parseFrom( + akka.protobufv3.internal.CodedInputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + akka.protobufv3.internal.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code ContextAwareRemoteEnvelope} + */ + public static final class Builder extends + akka.protobufv3.internal.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:ContextAwareRemoteEnvelope) + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelopeOrBuilder { + public static final akka.protobufv3.internal.Descriptors.Descriptor + getDescriptor() { + return ContextAwareWireFormats_Akka26.internal_static_ContextAwareRemoteEnvelope_descriptor; + } + + @java.lang.Override + protected akka.protobufv3.internal.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return ContextAwareWireFormats_Akka26.internal_static_ContextAwareRemoteEnvelope_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.class, ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.Builder.class); + } + + // Construct using akka.remote.ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + akka.protobufv3.internal.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (akka.protobufv3.internal.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getRecipientFieldBuilder(); + getMessageFieldBuilder(); + getSenderFieldBuilder(); + getTraceContextFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (recipientBuilder_ == null) { + recipient_ = null; + } else { + recipientBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + if (messageBuilder_ == null) { + message_ = null; + } else { + messageBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + if (senderBuilder_ == null) { + sender_ = null; + } else { + senderBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + seq_ = 0L; + bitField0_ = (bitField0_ & ~0x00000008); + if (traceContextBuilder_ == null) { + traceContext_ = null; + } else { + traceContextBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000010); + return this; + } + + @java.lang.Override + public akka.protobufv3.internal.Descriptors.Descriptor + getDescriptorForType() { + return ContextAwareWireFormats_Akka26.internal_static_ContextAwareRemoteEnvelope_descriptor; + } + + @java.lang.Override + public ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope getDefaultInstanceForType() { + return ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.getDefaultInstance(); + } + + @java.lang.Override + public ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope build() { + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope buildPartial() { + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope result = new ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + if (recipientBuilder_ == null) { + result.recipient_ = recipient_; + } else { + result.recipient_ = recipientBuilder_.build(); + } + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + if (messageBuilder_ == null) { + result.message_ = message_; + } else { + result.message_ = messageBuilder_.build(); + } + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + if (senderBuilder_ == null) { + result.sender_ = sender_; + } else { + result.sender_ = senderBuilder_.build(); + } + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.seq_ = seq_; + to_bitField0_ |= 0x00000008; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + if (traceContextBuilder_ == null) { + result.traceContext_ = traceContext_; + } else { + result.traceContext_ = traceContextBuilder_.build(); + } + to_bitField0_ |= 0x00000010; + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + akka.protobufv3.internal.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + akka.protobufv3.internal.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + akka.protobufv3.internal.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + akka.protobufv3.internal.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + akka.protobufv3.internal.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(akka.protobufv3.internal.Message other) { + if (other instanceof ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope) { + return mergeFrom((ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope other) { + if (other == ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope.getDefaultInstance()) return this; + if (other.hasRecipient()) { + mergeRecipient(other.getRecipient()); + } + if (other.hasMessage()) { + mergeMessage(other.getMessage()); + } + if (other.hasSender()) { + mergeSender(other.getSender()); + } + if (other.hasSeq()) { + setSeq(other.getSeq()); + } + if (other.hasTraceContext()) { + mergeTraceContext(other.getTraceContext()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + if (!hasRecipient()) { + return false; + } + if (!hasMessage()) { + return false; + } + if (!getRecipient().isInitialized()) { + return false; + } + if (!getMessage().isInitialized()) { + return false; + } + if (hasSender()) { + if (!getSender().isInitialized()) { + return false; + } + } + if (hasTraceContext()) { + if (!getTraceContext().isInitialized()) { + return false; + } + } + return true; + } + + @java.lang.Override + public Builder mergeFrom( + akka.protobufv3.internal.CodedInputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (akka.protobufv3.internal.InvalidProtocolBufferException e) { + parsedMessage = (ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private akka.remote.WireFormats.ActorRefData recipient_; + private akka.protobufv3.internal.SingleFieldBuilderV3< + akka.remote.WireFormats.ActorRefData, akka.remote.WireFormats.ActorRefData.Builder, akka.remote.WireFormats.ActorRefDataOrBuilder> recipientBuilder_; + /** + * required .ActorRefData recipient = 1; + */ + public boolean hasRecipient() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * required .ActorRefData recipient = 1; + */ + public akka.remote.WireFormats.ActorRefData getRecipient() { + if (recipientBuilder_ == null) { + return recipient_ == null ? akka.remote.WireFormats.ActorRefData.getDefaultInstance() : recipient_; + } else { + return recipientBuilder_.getMessage(); + } + } + /** + * required .ActorRefData recipient = 1; + */ + public Builder setRecipient(akka.remote.WireFormats.ActorRefData value) { + if (recipientBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + recipient_ = value; + onChanged(); + } else { + recipientBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .ActorRefData recipient = 1; + */ + public Builder setRecipient( + akka.remote.WireFormats.ActorRefData.Builder builderForValue) { + if (recipientBuilder_ == null) { + recipient_ = builderForValue.build(); + onChanged(); + } else { + recipientBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .ActorRefData recipient = 1; + */ + public Builder mergeRecipient(akka.remote.WireFormats.ActorRefData value) { + if (recipientBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) && + recipient_ != null && + recipient_ != akka.remote.WireFormats.ActorRefData.getDefaultInstance()) { + recipient_ = + akka.remote.WireFormats.ActorRefData.newBuilder(recipient_).mergeFrom(value).buildPartial(); + } else { + recipient_ = value; + } + onChanged(); + } else { + recipientBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .ActorRefData recipient = 1; + */ + public Builder clearRecipient() { + if (recipientBuilder_ == null) { + recipient_ = null; + onChanged(); + } else { + recipientBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + /** + * required .ActorRefData recipient = 1; + */ + public akka.remote.WireFormats.ActorRefData.Builder getRecipientBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getRecipientFieldBuilder().getBuilder(); + } + /** + * required .ActorRefData recipient = 1; + */ + public akka.remote.WireFormats.ActorRefDataOrBuilder getRecipientOrBuilder() { + if (recipientBuilder_ != null) { + return recipientBuilder_.getMessageOrBuilder(); + } else { + return recipient_ == null ? + akka.remote.WireFormats.ActorRefData.getDefaultInstance() : recipient_; + } + } + /** + * required .ActorRefData recipient = 1; + */ + private akka.protobufv3.internal.SingleFieldBuilderV3< + akka.remote.WireFormats.ActorRefData, akka.remote.WireFormats.ActorRefData.Builder, akka.remote.WireFormats.ActorRefDataOrBuilder> + getRecipientFieldBuilder() { + if (recipientBuilder_ == null) { + recipientBuilder_ = new akka.protobufv3.internal.SingleFieldBuilderV3< + akka.remote.WireFormats.ActorRefData, akka.remote.WireFormats.ActorRefData.Builder, akka.remote.WireFormats.ActorRefDataOrBuilder>( + getRecipient(), + getParentForChildren(), + isClean()); + recipient_ = null; + } + return recipientBuilder_; + } + + private akka.remote.WireFormats.SerializedMessage message_; + private akka.protobufv3.internal.SingleFieldBuilderV3< + akka.remote.WireFormats.SerializedMessage, akka.remote.WireFormats.SerializedMessage.Builder, akka.remote.WireFormats.SerializedMessageOrBuilder> messageBuilder_; + /** + * required .SerializedMessage message = 2; + */ + public boolean hasMessage() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * required .SerializedMessage message = 2; + */ + public akka.remote.WireFormats.SerializedMessage getMessage() { + if (messageBuilder_ == null) { + return message_ == null ? akka.remote.WireFormats.SerializedMessage.getDefaultInstance() : message_; + } else { + return messageBuilder_.getMessage(); + } + } + /** + * required .SerializedMessage message = 2; + */ + public Builder setMessage(akka.remote.WireFormats.SerializedMessage value) { + if (messageBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + message_ = value; + onChanged(); + } else { + messageBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * required .SerializedMessage message = 2; + */ + public Builder setMessage( + akka.remote.WireFormats.SerializedMessage.Builder builderForValue) { + if (messageBuilder_ == null) { + message_ = builderForValue.build(); + onChanged(); + } else { + messageBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * required .SerializedMessage message = 2; + */ + public Builder mergeMessage(akka.remote.WireFormats.SerializedMessage value) { + if (messageBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) && + message_ != null && + message_ != akka.remote.WireFormats.SerializedMessage.getDefaultInstance()) { + message_ = + akka.remote.WireFormats.SerializedMessage.newBuilder(message_).mergeFrom(value).buildPartial(); + } else { + message_ = value; + } + onChanged(); + } else { + messageBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + return this; + } + /** + * required .SerializedMessage message = 2; + */ + public Builder clearMessage() { + if (messageBuilder_ == null) { + message_ = null; + onChanged(); + } else { + messageBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + /** + * required .SerializedMessage message = 2; + */ + public akka.remote.WireFormats.SerializedMessage.Builder getMessageBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getMessageFieldBuilder().getBuilder(); + } + /** + * required .SerializedMessage message = 2; + */ + public akka.remote.WireFormats.SerializedMessageOrBuilder getMessageOrBuilder() { + if (messageBuilder_ != null) { + return messageBuilder_.getMessageOrBuilder(); + } else { + return message_ == null ? + akka.remote.WireFormats.SerializedMessage.getDefaultInstance() : message_; + } + } + /** + * required .SerializedMessage message = 2; + */ + private akka.protobufv3.internal.SingleFieldBuilderV3< + akka.remote.WireFormats.SerializedMessage, akka.remote.WireFormats.SerializedMessage.Builder, akka.remote.WireFormats.SerializedMessageOrBuilder> + getMessageFieldBuilder() { + if (messageBuilder_ == null) { + messageBuilder_ = new akka.protobufv3.internal.SingleFieldBuilderV3< + akka.remote.WireFormats.SerializedMessage, akka.remote.WireFormats.SerializedMessage.Builder, akka.remote.WireFormats.SerializedMessageOrBuilder>( + getMessage(), + getParentForChildren(), + isClean()); + message_ = null; + } + return messageBuilder_; + } + + private akka.remote.WireFormats.ActorRefData sender_; + private akka.protobufv3.internal.SingleFieldBuilderV3< + akka.remote.WireFormats.ActorRefData, akka.remote.WireFormats.ActorRefData.Builder, akka.remote.WireFormats.ActorRefDataOrBuilder> senderBuilder_; + /** + * optional .ActorRefData sender = 4; + */ + public boolean hasSender() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * optional .ActorRefData sender = 4; + */ + public akka.remote.WireFormats.ActorRefData getSender() { + if (senderBuilder_ == null) { + return sender_ == null ? akka.remote.WireFormats.ActorRefData.getDefaultInstance() : sender_; + } else { + return senderBuilder_.getMessage(); + } + } + /** + * optional .ActorRefData sender = 4; + */ + public Builder setSender(akka.remote.WireFormats.ActorRefData value) { + if (senderBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + sender_ = value; + onChanged(); + } else { + senderBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .ActorRefData sender = 4; + */ + public Builder setSender( + akka.remote.WireFormats.ActorRefData.Builder builderForValue) { + if (senderBuilder_ == null) { + sender_ = builderForValue.build(); + onChanged(); + } else { + senderBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .ActorRefData sender = 4; + */ + public Builder mergeSender(akka.remote.WireFormats.ActorRefData value) { + if (senderBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) && + sender_ != null && + sender_ != akka.remote.WireFormats.ActorRefData.getDefaultInstance()) { + sender_ = + akka.remote.WireFormats.ActorRefData.newBuilder(sender_).mergeFrom(value).buildPartial(); + } else { + sender_ = value; + } + onChanged(); + } else { + senderBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000004; + return this; + } + /** + * optional .ActorRefData sender = 4; + */ + public Builder clearSender() { + if (senderBuilder_ == null) { + sender_ = null; + onChanged(); + } else { + senderBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + /** + * optional .ActorRefData sender = 4; + */ + public akka.remote.WireFormats.ActorRefData.Builder getSenderBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getSenderFieldBuilder().getBuilder(); + } + /** + * optional .ActorRefData sender = 4; + */ + public akka.remote.WireFormats.ActorRefDataOrBuilder getSenderOrBuilder() { + if (senderBuilder_ != null) { + return senderBuilder_.getMessageOrBuilder(); + } else { + return sender_ == null ? + akka.remote.WireFormats.ActorRefData.getDefaultInstance() : sender_; + } + } + /** + * optional .ActorRefData sender = 4; + */ + private akka.protobufv3.internal.SingleFieldBuilderV3< + akka.remote.WireFormats.ActorRefData, akka.remote.WireFormats.ActorRefData.Builder, akka.remote.WireFormats.ActorRefDataOrBuilder> + getSenderFieldBuilder() { + if (senderBuilder_ == null) { + senderBuilder_ = new akka.protobufv3.internal.SingleFieldBuilderV3< + akka.remote.WireFormats.ActorRefData, akka.remote.WireFormats.ActorRefData.Builder, akka.remote.WireFormats.ActorRefDataOrBuilder>( + getSender(), + getParentForChildren(), + isClean()); + sender_ = null; + } + return senderBuilder_; + } + + private long seq_ ; + /** + * optional fixed64 seq = 5; + */ + public boolean hasSeq() { + return ((bitField0_ & 0x00000008) != 0); + } + /** + * optional fixed64 seq = 5; + */ + public long getSeq() { + return seq_; + } + /** + * optional fixed64 seq = 5; + */ + public Builder setSeq(long value) { + bitField0_ |= 0x00000008; + seq_ = value; + onChanged(); + return this; + } + /** + * optional fixed64 seq = 5; + */ + public Builder clearSeq() { + bitField0_ = (bitField0_ & ~0x00000008); + seq_ = 0L; + onChanged(); + return this; + } + + private ContextAwareWireFormats_Akka26.RemoteContext traceContext_; + private akka.protobufv3.internal.SingleFieldBuilderV3< + ContextAwareWireFormats_Akka26.RemoteContext, ContextAwareWireFormats_Akka26.RemoteContext.Builder, ContextAwareWireFormats_Akka26.RemoteContextOrBuilder> traceContextBuilder_; + /** + * optional .RemoteContext traceContext = 15; + */ + public boolean hasTraceContext() { + return ((bitField0_ & 0x00000010) != 0); + } + /** + * optional .RemoteContext traceContext = 15; + */ + public ContextAwareWireFormats_Akka26.RemoteContext getTraceContext() { + if (traceContextBuilder_ == null) { + return traceContext_ == null ? ContextAwareWireFormats_Akka26.RemoteContext.getDefaultInstance() : traceContext_; + } else { + return traceContextBuilder_.getMessage(); + } + } + /** + * optional .RemoteContext traceContext = 15; + */ + public Builder setTraceContext(ContextAwareWireFormats_Akka26.RemoteContext value) { + if (traceContextBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + traceContext_ = value; + onChanged(); + } else { + traceContextBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + return this; + } + /** + * optional .RemoteContext traceContext = 15; + */ + public Builder setTraceContext( + ContextAwareWireFormats_Akka26.RemoteContext.Builder builderForValue) { + if (traceContextBuilder_ == null) { + traceContext_ = builderForValue.build(); + onChanged(); + } else { + traceContextBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + return this; + } + /** + * optional .RemoteContext traceContext = 15; + */ + public Builder mergeTraceContext(ContextAwareWireFormats_Akka26.RemoteContext value) { + if (traceContextBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) && + traceContext_ != null && + traceContext_ != ContextAwareWireFormats_Akka26.RemoteContext.getDefaultInstance()) { + traceContext_ = + ContextAwareWireFormats_Akka26.RemoteContext.newBuilder(traceContext_).mergeFrom(value).buildPartial(); + } else { + traceContext_ = value; + } + onChanged(); + } else { + traceContextBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000010; + return this; + } + /** + * optional .RemoteContext traceContext = 15; + */ + public Builder clearTraceContext() { + if (traceContextBuilder_ == null) { + traceContext_ = null; + onChanged(); + } else { + traceContextBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000010); + return this; + } + /** + * optional .RemoteContext traceContext = 15; + */ + public ContextAwareWireFormats_Akka26.RemoteContext.Builder getTraceContextBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return getTraceContextFieldBuilder().getBuilder(); + } + /** + * optional .RemoteContext traceContext = 15; + */ + public ContextAwareWireFormats_Akka26.RemoteContextOrBuilder getTraceContextOrBuilder() { + if (traceContextBuilder_ != null) { + return traceContextBuilder_.getMessageOrBuilder(); + } else { + return traceContext_ == null ? + ContextAwareWireFormats_Akka26.RemoteContext.getDefaultInstance() : traceContext_; + } + } + /** + * optional .RemoteContext traceContext = 15; + */ + private akka.protobufv3.internal.SingleFieldBuilderV3< + ContextAwareWireFormats_Akka26.RemoteContext, ContextAwareWireFormats_Akka26.RemoteContext.Builder, ContextAwareWireFormats_Akka26.RemoteContextOrBuilder> + getTraceContextFieldBuilder() { + if (traceContextBuilder_ == null) { + traceContextBuilder_ = new akka.protobufv3.internal.SingleFieldBuilderV3< + ContextAwareWireFormats_Akka26.RemoteContext, ContextAwareWireFormats_Akka26.RemoteContext.Builder, ContextAwareWireFormats_Akka26.RemoteContextOrBuilder>( + getTraceContext(), + getParentForChildren(), + isClean()); + traceContext_ = null; + } + return traceContextBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final akka.protobufv3.internal.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final akka.protobufv3.internal.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:ContextAwareRemoteEnvelope) + } + + // @@protoc_insertion_point(class_scope:ContextAwareRemoteEnvelope) + private static final ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope(); + } + + public static ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + @java.lang.Deprecated public static final akka.protobufv3.internal.Parser + PARSER = new akka.protobufv3.internal.AbstractParser() { + @java.lang.Override + public ContextAwareRemoteEnvelope parsePartialFrom( + akka.protobufv3.internal.CodedInputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return new ContextAwareRemoteEnvelope(input, extensionRegistry); + } + }; + + public static akka.protobufv3.internal.Parser parser() { + return PARSER; + } + + @java.lang.Override + public akka.protobufv3.internal.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public ContextAwareWireFormats_Akka26.ContextAwareRemoteEnvelope getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface RemoteContextOrBuilder extends + // @@protoc_insertion_point(interface_extends:RemoteContext) + akka.protobufv3.internal.MessageOrBuilder { + + /** + * required bytes context = 1; + */ + boolean hasContext(); + /** + * required bytes context = 1; + */ + akka.protobufv3.internal.ByteString getContext(); + } + /** + * Protobuf type {@code RemoteContext} + */ + public static final class RemoteContext extends + akka.protobufv3.internal.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:RemoteContext) + RemoteContextOrBuilder { + private static final long serialVersionUID = 0L; + // Use RemoteContext.newBuilder() to construct. + private RemoteContext(akka.protobufv3.internal.GeneratedMessageV3.Builder builder) { + super(builder); + } + private RemoteContext() { + context_ = akka.protobufv3.internal.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new RemoteContext(); + } + + @java.lang.Override + public final akka.protobufv3.internal.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private RemoteContext( + akka.protobufv3.internal.CodedInputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + akka.protobufv3.internal.UnknownFieldSet.Builder unknownFields = + akka.protobufv3.internal.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + bitField0_ |= 0x00000001; + context_ = input.readBytes(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (akka.protobufv3.internal.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new akka.protobufv3.internal.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final akka.protobufv3.internal.Descriptors.Descriptor + getDescriptor() { + return ContextAwareWireFormats_Akka26.internal_static_RemoteContext_descriptor; + } + + @java.lang.Override + protected akka.protobufv3.internal.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return ContextAwareWireFormats_Akka26.internal_static_RemoteContext_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ContextAwareWireFormats_Akka26.RemoteContext.class, ContextAwareWireFormats_Akka26.RemoteContext.Builder.class); + } + + private int bitField0_; + public static final int CONTEXT_FIELD_NUMBER = 1; + private akka.protobufv3.internal.ByteString context_; + /** + * required bytes context = 1; + */ + public boolean hasContext() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * required bytes context = 1; + */ + public akka.protobufv3.internal.ByteString getContext() { + return context_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + if (!hasContext()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(akka.protobufv3.internal.CodedOutputStream output) + throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeBytes(1, context_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += akka.protobufv3.internal.CodedOutputStream + .computeBytesSize(1, context_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ContextAwareWireFormats_Akka26.RemoteContext)) { + return super.equals(obj); + } + ContextAwareWireFormats_Akka26.RemoteContext other = (ContextAwareWireFormats_Akka26.RemoteContext) obj; + + if (hasContext() != other.hasContext()) return false; + if (hasContext()) { + if (!getContext() + .equals(other.getContext())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasContext()) { + hash = (37 * hash) + CONTEXT_FIELD_NUMBER; + hash = (53 * hash) + getContext().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static ContextAwareWireFormats_Akka26.RemoteContext parseFrom( + java.nio.ByteBuffer data) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ContextAwareWireFormats_Akka26.RemoteContext parseFrom( + java.nio.ByteBuffer data, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.RemoteContext parseFrom( + akka.protobufv3.internal.ByteString data) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ContextAwareWireFormats_Akka26.RemoteContext parseFrom( + akka.protobufv3.internal.ByteString data, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.RemoteContext parseFrom(byte[] data) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ContextAwareWireFormats_Akka26.RemoteContext parseFrom( + byte[] data, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.RemoteContext parseFrom(java.io.InputStream input) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static ContextAwareWireFormats_Akka26.RemoteContext parseFrom( + java.io.InputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.RemoteContext parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static ContextAwareWireFormats_Akka26.RemoteContext parseDelimitedFrom( + java.io.InputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static ContextAwareWireFormats_Akka26.RemoteContext parseFrom( + akka.protobufv3.internal.CodedInputStream input) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static ContextAwareWireFormats_Akka26.RemoteContext parseFrom( + akka.protobufv3.internal.CodedInputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return akka.protobufv3.internal.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(ContextAwareWireFormats_Akka26.RemoteContext prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + akka.protobufv3.internal.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code RemoteContext} + */ + public static final class Builder extends + akka.protobufv3.internal.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:RemoteContext) + ContextAwareWireFormats_Akka26.RemoteContextOrBuilder { + public static final akka.protobufv3.internal.Descriptors.Descriptor + getDescriptor() { + return ContextAwareWireFormats_Akka26.internal_static_RemoteContext_descriptor; + } + + @java.lang.Override + protected akka.protobufv3.internal.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return ContextAwareWireFormats_Akka26.internal_static_RemoteContext_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ContextAwareWireFormats_Akka26.RemoteContext.class, ContextAwareWireFormats_Akka26.RemoteContext.Builder.class); + } + + // Construct using akka.remote.ContextAwareWireFormats_Akka26.RemoteContext.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + akka.protobufv3.internal.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (akka.protobufv3.internal.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + context_ = akka.protobufv3.internal.ByteString.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public akka.protobufv3.internal.Descriptors.Descriptor + getDescriptorForType() { + return ContextAwareWireFormats_Akka26.internal_static_RemoteContext_descriptor; + } + + @java.lang.Override + public ContextAwareWireFormats_Akka26.RemoteContext getDefaultInstanceForType() { + return ContextAwareWireFormats_Akka26.RemoteContext.getDefaultInstance(); + } + + @java.lang.Override + public ContextAwareWireFormats_Akka26.RemoteContext build() { + ContextAwareWireFormats_Akka26.RemoteContext result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public ContextAwareWireFormats_Akka26.RemoteContext buildPartial() { + ContextAwareWireFormats_Akka26.RemoteContext result = new ContextAwareWireFormats_Akka26.RemoteContext(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + to_bitField0_ |= 0x00000001; + } + result.context_ = context_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + akka.protobufv3.internal.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + akka.protobufv3.internal.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + akka.protobufv3.internal.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + akka.protobufv3.internal.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + akka.protobufv3.internal.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(akka.protobufv3.internal.Message other) { + if (other instanceof ContextAwareWireFormats_Akka26.RemoteContext) { + return mergeFrom((ContextAwareWireFormats_Akka26.RemoteContext)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(ContextAwareWireFormats_Akka26.RemoteContext other) { + if (other == ContextAwareWireFormats_Akka26.RemoteContext.getDefaultInstance()) return this; + if (other.hasContext()) { + setContext(other.getContext()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + if (!hasContext()) { + return false; + } + return true; + } + + @java.lang.Override + public Builder mergeFrom( + akka.protobufv3.internal.CodedInputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + ContextAwareWireFormats_Akka26.RemoteContext parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (akka.protobufv3.internal.InvalidProtocolBufferException e) { + parsedMessage = (ContextAwareWireFormats_Akka26.RemoteContext) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private akka.protobufv3.internal.ByteString context_ = akka.protobufv3.internal.ByteString.EMPTY; + /** + * required bytes context = 1; + */ + public boolean hasContext() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * required bytes context = 1; + */ + public akka.protobufv3.internal.ByteString getContext() { + return context_; + } + /** + * required bytes context = 1; + */ + public Builder setContext(akka.protobufv3.internal.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + context_ = value; + onChanged(); + return this; + } + /** + * required bytes context = 1; + */ + public Builder clearContext() { + bitField0_ = (bitField0_ & ~0x00000001); + context_ = getDefaultInstance().getContext(); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final akka.protobufv3.internal.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final akka.protobufv3.internal.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:RemoteContext) + } + + // @@protoc_insertion_point(class_scope:RemoteContext) + private static final ContextAwareWireFormats_Akka26.RemoteContext DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new ContextAwareWireFormats_Akka26.RemoteContext(); + } + + public static ContextAwareWireFormats_Akka26.RemoteContext getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + @java.lang.Deprecated public static final akka.protobufv3.internal.Parser + PARSER = new akka.protobufv3.internal.AbstractParser() { + @java.lang.Override + public RemoteContext parsePartialFrom( + akka.protobufv3.internal.CodedInputStream input, + akka.protobufv3.internal.ExtensionRegistryLite extensionRegistry) + throws akka.protobufv3.internal.InvalidProtocolBufferException { + return new RemoteContext(input, extensionRegistry); + } + }; + + public static akka.protobufv3.internal.Parser parser() { + return PARSER; + } + + @java.lang.Override + public akka.protobufv3.internal.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public ContextAwareWireFormats_Akka26.RemoteContext getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final akka.protobufv3.internal.Descriptors.Descriptor + internal_static_AckAndContextAwareEnvelopeContainer_descriptor; + private static final + akka.protobufv3.internal.GeneratedMessageV3.FieldAccessorTable + internal_static_AckAndContextAwareEnvelopeContainer_fieldAccessorTable; + private static final akka.protobufv3.internal.Descriptors.Descriptor + internal_static_ContextAwareRemoteEnvelope_descriptor; + private static final + akka.protobufv3.internal.GeneratedMessageV3.FieldAccessorTable + internal_static_ContextAwareRemoteEnvelope_fieldAccessorTable; + private static final akka.protobufv3.internal.Descriptors.Descriptor + internal_static_RemoteContext_descriptor; + private static final + akka.protobufv3.internal.GeneratedMessageV3.FieldAccessorTable + internal_static_RemoteContext_fieldAccessorTable; + + public static akka.protobufv3.internal.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static akka.protobufv3.internal.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\035ContextAwareWireFormats.proto\032\021WireFor" + + "mats.proto\"w\n#AckAndContextAwareEnvelope" + + "Container\022!\n\003ack\030\001 \001(\0132\024.Acknowledgement" + + "Info\022-\n\010envelope\030\002 \001(\0132\033.ContextAwareRem" + + "oteEnvelope\"\265\001\n\032ContextAwareRemoteEnvelo" + + "pe\022 \n\trecipient\030\001 \002(\0132\r.ActorRefData\022#\n\007" + + "message\030\002 \002(\0132\022.SerializedMessage\022\035\n\006sen" + + "der\030\004 \001(\0132\r.ActorRefData\022\013\n\003seq\030\005 \001(\006\022$\n" + + "\014traceContext\030\017 \001(\0132\016.RemoteContext\" \n\rR" + + "emoteContext\022\017\n\007context\030\001 \002(\014B\017\n\013akka.re" + + "moteH\001" + }; + descriptor = akka.protobufv3.internal.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new akka.protobufv3.internal.Descriptors.FileDescriptor[] { + akka.remote.WireFormats.getDescriptor(), + }); + internal_static_AckAndContextAwareEnvelopeContainer_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_AckAndContextAwareEnvelopeContainer_fieldAccessorTable = new + akka.protobufv3.internal.GeneratedMessageV3.FieldAccessorTable( + internal_static_AckAndContextAwareEnvelopeContainer_descriptor, + new java.lang.String[] { "Ack", "Envelope", }); + internal_static_ContextAwareRemoteEnvelope_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_ContextAwareRemoteEnvelope_fieldAccessorTable = new + akka.protobufv3.internal.GeneratedMessageV3.FieldAccessorTable( + internal_static_ContextAwareRemoteEnvelope_descriptor, + new java.lang.String[] { "Recipient", "Message", "Sender", "Seq", "TraceContext", }); + internal_static_RemoteContext_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_RemoteContext_fieldAccessorTable = new + akka.protobufv3.internal.GeneratedMessageV3.FieldAccessorTable( + internal_static_RemoteContext_descriptor, + new java.lang.String[] { "Context", }); + akka.remote.WireFormats.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/instrumentation/akka-2.6/src/main/protobuf/ContextAwareWireFormats.proto b/instrumentation/akka-2.6/src/main/protobuf/ContextAwareWireFormats.proto new file mode 100644 index 0000000..dd493bf --- /dev/null +++ b/instrumentation/akka-2.6/src/main/protobuf/ContextAwareWireFormats.proto @@ -0,0 +1,30 @@ +syntax = "proto2"; +import "WireFormats.proto"; + + +option java_package = "akka.remote"; +option optimize_for = SPEED; + + +/************************************************ + * Kamon-specific additions to the protocol + ************************************************/ + +message AckAndContextAwareEnvelopeContainer { + optional AcknowledgementInfo ack = 1; + optional ContextAwareRemoteEnvelope envelope = 2; +} + +message ContextAwareRemoteEnvelope { + required ActorRefData recipient = 1; + required SerializedMessage message = 2; + optional ActorRefData sender = 4; + optional fixed64 seq = 5; + + optional RemoteContext traceContext = 15; +} + +message RemoteContext { + required bytes context = 1; +} + diff --git a/instrumentation/akka-2.6/src/main/protobuf/WireFormats.proto b/instrumentation/akka-2.6/src/main/protobuf/WireFormats.proto new file mode 100644 index 0000000..85500c4 --- /dev/null +++ b/instrumentation/akka-2.6/src/main/protobuf/WireFormats.proto @@ -0,0 +1,132 @@ +/** + * Copyright (C) 2009-2014 Typesafe Inc. + */ + +// Extracted from https://github.com/akka/akka/blob/master/akka-remote/src/main/protobuf/WireFormats.proto + +syntax = "proto2"; +option java_package = "akka.remote"; +option optimize_for = SPEED; + +/****************************************** + * Remoting message formats + ******************************************/ + + +message AckAndEnvelopeContainer { + optional AcknowledgementInfo ack = 1; + optional RemoteEnvelope envelope = 2; +} + +/** + * Defines a remote message. + */ +message RemoteEnvelope { + required ActorRefData recipient = 1; + required SerializedMessage message = 2; + optional ActorRefData sender = 4; + optional fixed64 seq = 5; +} + +message AcknowledgementInfo { + required fixed64 cumulativeAck = 1; + repeated fixed64 nacks = 2; +} + +/** + * Defines a remote ActorRef that "remembers" and uses its original Actor instance + * on the original node. + */ +message ActorRefData { + required string path = 1; +} + +/** + * Defines a message. + */ +message SerializedMessage { + required bytes message = 1; + required int32 serializerId = 2; + optional bytes messageManifest = 3; +} + +/** + * Defines akka.remote.DaemonMsgCreate + */ +message DaemonMsgCreateData { + required PropsData props = 1; + required DeployData deploy = 2; + required string path = 3; + required ActorRefData supervisor = 4; +} + +/** + * Serialization of akka.actor.Props + */ +message PropsData { + required DeployData deploy = 2; + required string clazz = 3; + repeated bytes args = 4; + repeated string classes = 5; +} + +/** + * Serialization of akka.actor.Deploy + */ +message DeployData { + required string path = 1; + optional bytes config = 2; + optional bytes routerConfig = 3; + optional bytes scope = 4; + optional string dispatcher = 5; +} + + +/****************************************** + * Akka Protocol message formats + ******************************************/ + +/** + * Message format of Akka Protocol. + * Message contains either a payload or an instruction. + */ +message AkkaProtocolMessage { + optional bytes payload = 1; + optional AkkaControlMessage instruction = 2; +} + +/** + * Defines some control messages for the remoting + */ +message AkkaControlMessage { + required CommandType commandType = 1; + optional AkkaHandshakeInfo handshakeInfo = 2; +} + +message AkkaHandshakeInfo { + required AddressData origin = 1; + required fixed64 uid = 2; + optional string cookie = 3; + +} + +/** + * Defines the type of the AkkaControlMessage command type + */ +enum CommandType { + ASSOCIATE = 1; + DISASSOCIATE = 2; + HEARTBEAT = 3; + DISASSOCIATE_SHUTTING_DOWN = 4; // Remote system is going down and will not accepts new connections + DISASSOCIATE_QUARANTINED = 5; // Remote system refused the association since the current system is quarantined +} + +/** + * Defines a remote address. + */ +message AddressData { + required string system = 1; + required string hostname = 2; + required uint32 port = 3; + optional string protocol = 4; +} \ No newline at end of file diff --git a/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/DispatcherInstrumentation.scala b/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/DispatcherInstrumentation.scala new file mode 100644 index 0000000..8c9088c --- /dev/null +++ b/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/DispatcherInstrumentation.scala @@ -0,0 +1,120 @@ +/* + * ========================================================================================= + * Copyright © 2013-2018 the kamon project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + * ========================================================================================= + */ + +package kamon.instrumentation.akka.instrumentations.akka_26 + +import java.util.concurrent.{Callable, ExecutorService} + +import akka.dispatch.{DispatcherPrerequisites, ForkJoinExecutorConfigurator, PinnedDispatcherConfigurator, ThreadPoolExecutorConfigurator} +import kamon.instrumentation.akka.instrumentations.VersionFiltering +import kamon.Kamon +import kamon.instrumentation.akka.AkkaInstrumentation +import kamon.instrumentation.akka.instrumentations.DispatcherInfo.{HasActorSystemName, HasDispatcherName} +import kamon.instrumentation.executor.ExecutorInstrumentation +import kamon.tag.TagSet +import kanela.agent.api.instrumentation.InstrumentationBuilder +import kanela.agent.libs.net.bytebuddy.asm.Advice +import kanela.agent.libs.net.bytebuddy.implementation.bind.annotation.{SuperCall, This} + +class DispatcherInstrumentation extends InstrumentationBuilder with VersionFiltering { + + onAkka("2.6") { + + /** + * This is where the actual ExecutorService instances are being created, but at this point we don't have access to + * the Actor System Name nor the Dispatcher name, which is why there is additional instrumentation to carry these two + * names down to the ExecutorServiceFactory and use them to tag the newly instrumented ExecutorService. + */ + onSubTypesOf("akka.dispatch.ExecutorServiceFactory") + .mixin(classOf[HasActorSystemName.Mixin]) + .mixin(classOf[HasDispatcherName.Mixin]) + .intercept(method("createExecutorService"), InstrumentNewExecutorServiceOnAkka26) + + /** + * First step on getting the Actor System name is to read it from the prerequisites instance passed to the + * constructors of these two classes. + */ + onTypes("akka.dispatch.ThreadPoolExecutorConfigurator", "akka.dispatch.ForkJoinExecutorConfigurator", "akka.dispatch.PinnedDispatcherConfigurator") + .advise(isConstructor, CaptureActorSystemNameOnExecutorConfigurator) + + /** + * Copies the Actor System and Dispatcher names to the ExecutorServiceFactory instances for the two types of + * executors instrumented by Kamon. + */ + onTypes("akka.dispatch.ThreadPoolConfig", "akka.dispatch.ForkJoinExecutorConfigurator", "akka.dispatch.PinnedDispatcherConfigurator") + .mixin(classOf[HasActorSystemName.Mixin]) + .mixin(classOf[HasDispatcherName.Mixin]) + .advise(method("createExecutorServiceFactory"), CopyDispatcherInfoToExecutorServiceFactory) + + /** + * This ensures that the ActorSystem name is not lost when creating PinnedDispatcher instances. + */ + onType("akka.dispatch.ThreadPoolConfig") + .advise(method("copy"), ThreadPoolConfigCopyAdvice) + } + +} + +object CaptureActorSystemNameOnExecutorConfigurator { + + @Advice.OnMethodExit(suppress = classOf[Throwable]) + def exit(@Advice.This configurator: Any, @Advice.Argument(1) prerequisites: DispatcherPrerequisites): Unit = { + val actorSystemName = prerequisites.settings.name + + configurator match { + case fjec: ForkJoinExecutorConfigurator => fjec.asInstanceOf[HasActorSystemName].setActorSystemName(actorSystemName) + case tpec: ThreadPoolExecutorConfigurator => tpec.threadPoolConfig.asInstanceOf[HasActorSystemName].setActorSystemName(actorSystemName) + case pdc: PinnedDispatcherConfigurator => pdc.asInstanceOf[HasActorSystemName].setActorSystemName(actorSystemName) + case _ => // just ignore any other case. + } + } +} + +object CopyDispatcherInfoToExecutorServiceFactory { + + @Advice.OnMethodExit + def exit(@Advice.This poolConfig: HasActorSystemName, @Advice.Argument(0) dispatcherName: String, @Advice.Return factory: Any): Unit = { + val factoryWithMixins = factory.asInstanceOf[HasDispatcherName with HasActorSystemName] + factoryWithMixins.setActorSystemName(poolConfig.actorSystemName) + factoryWithMixins.setDispatcherName(dispatcherName) + } +} + +object InstrumentNewExecutorServiceOnAkka26 { + + def around(@This factory: HasActorSystemName with HasDispatcherName, @SuperCall callable: Callable[ExecutorService]): ExecutorService = { + val executor = callable.call() + val name = factory.dispatcherName + val systemTags = TagSet.of("akka.system", factory.actorSystemName) + + if(Kamon.filter(AkkaInstrumentation.TrackDispatcherFilterName).accept(name)) { + executor match { + case otherExecutor => + ExecutorInstrumentation.instrument(otherExecutor, name, systemTags) + } + + } else executor + } +} + +object ThreadPoolConfigCopyAdvice { + + @Advice.OnMethodExit + def exit(@Advice.This original: Any, @Advice.Return copy: Any): Unit = { + copy.asInstanceOf[HasActorSystemName].setActorSystemName(original.asInstanceOf[HasActorSystemName].actorSystemName) + copy.asInstanceOf[HasDispatcherName].setDispatcherName(original.asInstanceOf[HasDispatcherName].dispatcherName) + } +} diff --git a/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/RemotingInstrumentation.scala b/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/RemotingInstrumentation.scala new file mode 100644 index 0000000..a5d3f8d --- /dev/null +++ b/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/RemotingInstrumentation.scala @@ -0,0 +1,182 @@ +package kamon.instrumentation.akka.instrumentations.akka_26.remote + +import akka.actor.ActorSystem +import akka.remote.kamon.instrumentation.akka.instrumentations.akka_26.remote.{CaptureContextOnInboundEnvelope, DeserializeForArteryAdvice, SerializeForArteryAdvice} +import akka.kamon.instrumentation.akka.instrumentations.akka_26.remote.internal.{AkkaPduProtobufCodecConstructMessageMethodInterceptor, AkkaPduProtobufCodecDecodeMessage} +import kamon.Kamon +import kamon.context.Storage +import kamon.context.Storage.Scope +import kamon.instrumentation.akka.AkkaRemoteInstrumentation +import kamon.instrumentation.akka.AkkaRemoteMetrics.SerializationInstruments +import kamon.instrumentation.akka.instrumentations.{AkkaPrivateAccess, VersionFiltering} +import kamon.instrumentation.context.{CaptureCurrentContextOnExit, HasContext} +import kanela.agent.api.instrumentation.InstrumentationBuilder +import kanela.agent.libs.net.bytebuddy.asm.Advice + + +class RemotingInstrumentation extends InstrumentationBuilder with VersionFiltering { + + onAkka("2.6") { + + /** + * Send messages might be buffered if they reach the EndpointWriter before it has been initialized and the current + * Context might be lost after the buffering, so we make sure we capture the context when the Send command was + * created and then apply it during the EndpointWrite.writeSend method execution (see bellow). + */ + onType("akka.remote.EndpointManager$Send") + .mixin(classOf[HasContext.Mixin]) + .advise(isConstructor, CaptureCurrentContextOnExit) + + onType("akka.remote.EndpointWriter") + .advise(method("writeSend"), WriteSendWithContext) + + /** + * Reads and writes the Akka PDU using a modified version of the Protobuf that has an extra field for a Context + * instance. + */ + onType("akka.remote.transport.AkkaPduProtobufCodec$") + .intercept(method("constructMessage"), new AkkaPduProtobufCodecConstructMessageMethodInterceptor()) + .advise(method("decodeMessage"), classOf[AkkaPduProtobufCodecDecodeMessage]) + + /** + * Mixin Serialization Instruments to the Actor System and use them to record the serialization and deserialization + * time metrics. + */ + onType("akka.actor.ActorSystemImpl") + .mixin(classOf[HasSerializationInstruments.Mixin]) + .advise(isConstructor, InitializeActorSystemAdvice) + + onType("akka.remote.MessageSerializer$") + .advise(method("serialize"), MeasureSerializationTime) + .advise(method("deserialize"), MeasureDeserializationTime) + + + /** + * Artery + */ + onType("akka.remote.artery.ReusableOutboundEnvelope") + .mixin(classOf[HasContext.Mixin]) + .advise(method("copy"), CopyContextOnReusableEnvelope) + + onType("akka.remote.artery.Association") + .advise(method("createOutboundEnvelope$1"), CaptureCurrentContextOnReusableEnvelope) + + onType("akka.remote.MessageSerializer$") + .advise(method("serializeForArtery"), classOf[SerializeForArteryAdvice]) + .advise(method("deserializeForArtery"), classOf[DeserializeForArteryAdvice]) + + onType("akka.remote.artery.ReusableInboundEnvelope") + .mixin(classOf[HasContext.Mixin]) + .advise(method("withMessage"), classOf[CaptureContextOnInboundEnvelope]) + .advise(method("copyForLane"), CopyContextOnReusableEnvelope) + + onType("akka.remote.artery.MessageDispatcher") + .advise(method("dispatch"), ArteryMessageDispatcherAdvice) + } + +} + +object ArteryMessageDispatcherAdvice { + + @Advice.OnMethodEnter + def enter(@Advice.Argument(0) envelope: Any): Storage.Scope = + Kamon.storeContext(envelope.asInstanceOf[HasContext].context) + + @Advice.OnMethodExit + def exit(@Advice.Enter scope: Storage.Scope): Unit = + scope.close() +} + +object CopyContextOnReusableEnvelope { + + @Advice.OnMethodExit + def exit(@Advice.This oldEnvelope: Any, @Advice.Return newEnvelope: Any): Unit = + newEnvelope.asInstanceOf[HasContext].setContext(oldEnvelope.asInstanceOf[HasContext].context) +} + +object CaptureCurrentContextOnReusableEnvelope { + + @Advice.OnMethodExit + def exit(@Advice.Return envelope: Any): Unit = { + envelope.asInstanceOf[HasContext].setContext(Kamon.currentContext()) + } +} + +object WriteSendWithContext { + + @Advice.OnMethodEnter + def enter(@Advice.Argument(0) send: Any): Scope = { + Kamon.storeContext(send.asInstanceOf[HasContext].context) + } + + @Advice.OnMethodExit + def exit(@Advice.Enter scope: Scope): Unit = { + scope.asInstanceOf[Scope].close() + } +} + +trait HasSerializationInstruments { + def serializationInstruments: SerializationInstruments + def setSerializationInstruments(instruments: SerializationInstruments): Unit +} + +object HasSerializationInstruments { + + class Mixin(var serializationInstruments: SerializationInstruments) extends HasSerializationInstruments { + override def setSerializationInstruments(instruments: SerializationInstruments): Unit = + serializationInstruments = instruments + } +} + +object InitializeActorSystemAdvice { + + @Advice.OnMethodExit + def exit(@Advice.This system: ActorSystem with HasSerializationInstruments): Unit = + system.setSerializationInstruments(new SerializationInstruments(system.name)) + +} + +object MeasureSerializationTime { + + @Advice.OnMethodEnter + def enter(): Long = { + if(AkkaRemoteInstrumentation.settings().trackSerializationMetrics) System.nanoTime() else 0L + } + + @Advice.OnMethodExit + def exit(@Advice.Argument(0) system: AnyRef, @Advice.Enter startNanoTime: Long): Unit = { + if(startNanoTime != 0L) { + system.asInstanceOf[HasSerializationInstruments] + .serializationInstruments + .serializationTime + .record(System.nanoTime() - startNanoTime) + } + } +} + +object MeasureDeserializationTime { + + @Advice.OnMethodEnter + def enter(): Long = { + if(AkkaRemoteInstrumentation.settings().trackSerializationMetrics) System.nanoTime() else 0L + } + + @Advice.OnMethodExit + def exit(@Advice.Argument(0) system: AnyRef, @Advice.Enter startNanoTime: Long, @Advice.Return msg: Any): Unit = { + + if(AkkaPrivateAccess.isSystemMessage(msg)) { + msg match { + case hc: HasContext if hc.context == null => + hc.setContext(Kamon.currentContext()) + case _ => + } + } + + if(startNanoTime != 0L) { + system.asInstanceOf[HasSerializationInstruments] + .serializationInstruments + .deserializationTime + .record(System.nanoTime() - startNanoTime) + } + } +} diff --git a/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/internal/AkkaPduProtobufCodecConstructMessageMethodInterceptor.scala b/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/internal/AkkaPduProtobufCodecConstructMessageMethodInterceptor.scala new file mode 100644 index 0000000..63d57fb --- /dev/null +++ b/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/internal/AkkaPduProtobufCodecConstructMessageMethodInterceptor.scala @@ -0,0 +1,81 @@ +package akka.kamon.instrumentation.akka.instrumentations.akka_26.remote.internal + +import java.io.ByteArrayOutputStream + +import akka.KamonOptionVal.OptionVal +import akka.actor.{ActorRef, Address} +import akka.remote.ContextAwareWireFormats_Akka26.{AckAndContextAwareEnvelopeContainer, ContextAwareRemoteEnvelope, RemoteContext} +import akka.remote.WireFormats.{AcknowledgementInfo, ActorRefData, AddressData, SerializedMessage} +import akka.remote.{Ack, SeqNo} +import akka.util.ByteString +import kamon.Kamon +import kamon.context.BinaryPropagation.ByteStreamWriter +import kamon.instrumentation.akka.AkkaRemoteMetrics +import kanela.agent.libs.net.bytebuddy.implementation.bind.annotation.{Argument, RuntimeType} + +/** + * Interceptor for akka.remote.transport.AkkaPduProtobufCodec$::constructMessage + */ +class AkkaPduProtobufCodecConstructMessageMethodInterceptor { + + @RuntimeType + def aroundConstructMessage(@Argument(0) localAddress: Address, + @Argument(1) recipient: ActorRef, + @Argument(2) serializedMessage: SerializedMessage, + @Argument(3) senderOption: OptionVal[ActorRef], + @Argument(4) seqOption: Option[SeqNo], + @Argument(5) ackOption: Option[Ack]): AnyRef = { + + val ackAndEnvelopeBuilder = AckAndContextAwareEnvelopeContainer.newBuilder + val envelopeBuilder = ContextAwareRemoteEnvelope.newBuilder + + envelopeBuilder.setRecipient(serializeActorRef(recipient.path.address, recipient)) + if (senderOption.isDefined) + envelopeBuilder.setSender(serializeActorRef(localAddress, senderOption.get)) + seqOption foreach { seq => envelopeBuilder.setSeq(seq.rawValue) } + ackOption foreach { ack => ackAndEnvelopeBuilder.setAck(ackBuilder(ack)) } + envelopeBuilder.setMessage(serializedMessage) + + val out = new ByteArrayOutputStream() + Kamon.defaultBinaryPropagation().write(Kamon.currentContext(), ByteStreamWriter.of(out)) + + val remoteTraceContext = RemoteContext.newBuilder().setContext( + akka.protobufv3.internal.ByteString.copyFrom(out.toByteArray) + ) + envelopeBuilder.setTraceContext(remoteTraceContext) + + ackAndEnvelopeBuilder.setEnvelope(envelopeBuilder) + + val messageSize = envelopeBuilder.getMessage.getMessage.size() + AkkaRemoteMetrics.serializationInstruments(localAddress.system).outboundMessageSize.record(messageSize) + + ByteString.ByteString1C(ackAndEnvelopeBuilder.build.toByteArray) //Reuse Byte Array (naughty!) + } + + // Copied from akka.remote.transport.AkkaPduProtobufCodec because of private access. + private def ackBuilder(ack: Ack): AcknowledgementInfo.Builder = { + val ackBuilder = AcknowledgementInfo.newBuilder() + ackBuilder.setCumulativeAck(ack.cumulativeAck.rawValue) + ack.nacks foreach { nack => ackBuilder.addNacks(nack.rawValue) } + ackBuilder + } + + // Copied from akka.remote.transport.AkkaPduProtobufCodec because of private access. + private def serializeActorRef(defaultAddress: Address, ref: ActorRef): ActorRefData = { + ActorRefData.newBuilder.setPath( + if (ref.path.address.host.isDefined) ref.path.toSerializationFormat + else ref.path.toSerializationFormatWithAddress(defaultAddress)).build() + } + + // Copied from akka.remote.transport.AkkaPduProtobufCodec because of private access. + private def serializeAddress(address: Address): AddressData = address match { + case Address(protocol, system, Some(host), Some(port)) => + AddressData.newBuilder + .setHostname(host) + .setPort(port) + .setSystem(system) + .setProtocol(protocol) + .build() + case _ => throw new IllegalArgumentException(s"Address [$address] could not be serialized: host or port missing.") + } +} \ No newline at end of file diff --git a/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/internal/AkkaPduProtobufCodecDecodeMessageMethodAdvisor.scala b/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/internal/AkkaPduProtobufCodecDecodeMessageMethodAdvisor.scala new file mode 100644 index 0000000..54e1f60 --- /dev/null +++ b/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/internal/AkkaPduProtobufCodecDecodeMessageMethodAdvisor.scala @@ -0,0 +1,34 @@ +package akka.kamon.instrumentation.akka.instrumentations.akka_26.remote.internal + +import akka.actor.Address +import akka.remote.ContextAwareWireFormats_Akka26.AckAndContextAwareEnvelopeContainer +import akka.remote.RemoteActorRefProvider +import akka.util.ByteString +import kamon.Kamon +import kamon.context.BinaryPropagation.ByteStreamReader +import kamon.instrumentation.akka.AkkaRemoteMetrics +import kanela.agent.libs.net.bytebuddy.asm.Advice.{Argument, OnMethodEnter} + +/** + * Advisor for akka.remote.transport.AkkaPduProtobufCodec$::decodeMessage + */ +class AkkaPduProtobufCodecDecodeMessage + +object AkkaPduProtobufCodecDecodeMessage { + + @OnMethodEnter + def enter(@Argument(0) bs: ByteString, @Argument(1) provider: RemoteActorRefProvider, @Argument(2) localAddress: Address): Unit = { + val ackAndEnvelope = AckAndContextAwareEnvelopeContainer.parseFrom(bs.toArray) + if (ackAndEnvelope.hasEnvelope && ackAndEnvelope.getEnvelope.hasTraceContext) { + val remoteCtx = ackAndEnvelope.getEnvelope.getTraceContext + + if(remoteCtx.getContext.size() > 0) { + val ctx = Kamon.defaultBinaryPropagation().read(ByteStreamReader.of(remoteCtx.getContext.toByteArray)) + Kamon.storeContext(ctx) + } + + val messageSize = ackAndEnvelope.getEnvelope.getMessage.getMessage.size() + AkkaRemoteMetrics.serializationInstruments(localAddress.system).inboundMessageSize.record(messageSize) + } + } +} diff --git a/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/internal/ArterySerializationAdvice.scala b/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/internal/ArterySerializationAdvice.scala new file mode 100644 index 0000000..e72bd69 --- /dev/null +++ b/instrumentation/akka-2.6/src/main/scala/kamon/instrumentation/akka/instrumentations/akka_26/remote/internal/ArterySerializationAdvice.scala @@ -0,0 +1,153 @@ +package akka.remote.kamon.instrumentation.akka.instrumentations.akka_26.remote + +import java.nio.ByteBuffer + +import akka.actor.ActorSystem +import akka.remote.artery.{EnvelopeBuffer, OutboundEnvelope} +import akka.serialization.Serialization +import kamon.Kamon +import kamon.context.{BinaryPropagation, Context} +import kamon.instrumentation.akka.AkkaRemoteMetrics +import kamon.instrumentation.context.HasContext +import kanela.agent.libs.net.bytebuddy.asm.Advice + + +/** + * For Artery messages we will always add two sections to the end of each serialized message: the Context and the size + * of the Context. The layout will look something like this: + * + * |------------------ Actual Message ------------------||-- Kamon Context --||-- Context Size (4 bytes) --| + * + * If the Context is empty the Context size will be zero. + */ + +class SerializeForArteryAdvice +object SerializeForArteryAdvice { + + @Advice.OnMethodEnter + def enter(): Long = { + System.nanoTime() + } + + @Advice.OnMethodExit + def exit(@Advice.Argument(0) serialization: Serialization, @Advice.Argument(1) envelope: OutboundEnvelope, + @Advice.Argument(3) envelopeBuffer: EnvelopeBuffer, @Advice.Enter startTime: Long): Unit = { + + val instruments = AkkaRemoteMetrics.serializationInstruments(serialization.system.name) + val messageBuffer = envelopeBuffer.byteBuffer + val context = envelope.asInstanceOf[HasContext].context + val positionBeforeContext = messageBuffer.position() + + if(context.nonEmpty()) { + Kamon.defaultBinaryPropagation().write(context, byteBufferWriter(messageBuffer)) + } + + instruments.serializationTime.record(System.nanoTime() - startTime) + instruments.outboundMessageSize.record(positionBeforeContext) + + val contextSize = messageBuffer.position() - positionBeforeContext + messageBuffer.putInt(contextSize) + } + + def byteBufferWriter(bb: ByteBuffer): BinaryPropagation.ByteStreamWriter = new BinaryPropagation.ByteStreamWriter { + override def write(bytes: Array[Byte]): Unit = + bb.put(bytes) + + override def write(bytes: Array[Byte], offset: Int, count: Int): Unit = + bb.put(bytes, offset, count) + + override def write(byte: Int): Unit = + bb.put(byte.toByte) + } +} + +class DeserializeForArteryAdvice +object DeserializeForArteryAdvice { + + val LastDeserializedContext = new ThreadLocal[Context]() { + override def initialValue(): Context = null + } + + case class DeserializationInfo( + context: Context, + timeStamp: Long, + messageSize: Long + ) + + @Advice.OnMethodEnter + def exit(@Advice.Argument(5) envelopeBuffer: EnvelopeBuffer): DeserializationInfo = { + val startTime = System.nanoTime() + val messageBuffer = envelopeBuffer.byteBuffer + val messageStart = messageBuffer.position() + + messageBuffer.mark() + messageBuffer.position(messageBuffer.limit() - 4) + val contextSize = messageBuffer.getInt() + val contextStart = messageBuffer.limit() - (contextSize + 4) + val messageSize = contextStart - messageStart + + val context = if(contextSize == 0) + Context.Empty + else { + messageBuffer + .position(contextStart) + .limit(contextStart + contextSize) + + Kamon.defaultBinaryPropagation().read(byteBufferReader(messageBuffer)) + } + + messageBuffer.reset() + messageBuffer.limit(contextStart) + DeserializationInfo(context, startTime, messageSize) + } + + @Advice.OnMethodExit(onThrowable = classOf[Throwable]) + def exit(@Advice.Argument(0) system: ActorSystem, @Advice.Argument(5) envelopeBuffer: EnvelopeBuffer, + @Advice.Enter deserializationInfo: DeserializationInfo, @Advice.Thrown error: Throwable): Unit = { + + if(error == null) { + LastDeserializedContext.set(deserializationInfo.context) + + val instruments = AkkaRemoteMetrics.serializationInstruments(system.name) + instruments.deserializationTime.record(System.nanoTime() - deserializationInfo.timeStamp) + instruments.inboundMessageSize.record(deserializationInfo.messageSize) + } + } + + + def byteBufferReader(bb: ByteBuffer): BinaryPropagation.ByteStreamReader = new BinaryPropagation.ByteStreamReader { + override def available(): Int = + bb.remaining() + + override def read(target: Array[Byte]): Int = { + bb.get(target) + target.length + } + + override def read(target: Array[Byte], offset: Int, count: Int): Int = { + bb.get(target, offset, count) + target.length + } + + override def readAll(): Array[Byte] = { + val array = Array.ofDim[Byte](bb.remaining()) + bb.get(array) + array + } + } +} + + +class CaptureContextOnInboundEnvelope +object CaptureContextOnInboundEnvelope { + + @Advice.OnMethodEnter + def enter(@Advice.This inboundEnvelope: Any): Unit = { + val lastContext = DeserializeForArteryAdvice.LastDeserializedContext.get() + if(lastContext != null) { + inboundEnvelope.asInstanceOf[HasContext].setContext(lastContext) + DeserializeForArteryAdvice.LastDeserializedContext.set(null) + } + } + +} \ No newline at end of file diff --git a/kamon-akka/src/main/java/kamon/instrumentation/akka/instrumentations/ActorCellInvokeAdvice.java b/instrumentation/common/src/main/java/kamon/instrumentation/akka/instrumentations/ActorCellInvokeAdvice.java similarity index 100% rename from kamon-akka/src/main/java/kamon/instrumentation/akka/instrumentations/ActorCellInvokeAdvice.java rename to instrumentation/common/src/main/java/kamon/instrumentation/akka/instrumentations/ActorCellInvokeAdvice.java diff --git a/kamon-akka/src/main/java/kamon/instrumentation/akka/instrumentations/AkkaPrivateAccess.java b/instrumentation/common/src/main/java/kamon/instrumentation/akka/instrumentations/AkkaPrivateAccess.java similarity index 100% rename from kamon-akka/src/main/java/kamon/instrumentation/akka/instrumentations/AkkaPrivateAccess.java rename to instrumentation/common/src/main/java/kamon/instrumentation/akka/instrumentations/AkkaPrivateAccess.java diff --git a/kamon-akka/src/main/resources/reference.conf b/instrumentation/common/src/main/resources/reference.conf similarity index 95% rename from kamon-akka/src/main/resources/reference.conf rename to instrumentation/common/src/main/resources/reference.conf index e4b528e..d93b956 100644 --- a/kamon-akka/src/main/resources/reference.conf +++ b/instrumentation/common/src/main/resources/reference.conf @@ -136,11 +136,12 @@ kanela.modules { "kamon.instrumentation.akka.instrumentations.SystemMessageInstrumentation", "kamon.instrumentation.akka.instrumentations.RouterInstrumentation", "kamon.instrumentation.akka.instrumentations.ActorInstrumentation", - "kamon.instrumentation.akka.instrumentations.DispatcherInstrumentation", "kamon.instrumentation.akka.instrumentations.ActorLoggingInstrumentation", "kamon.instrumentation.akka.instrumentations.AskPatternInstrumentation", "kamon.instrumentation.akka.instrumentations.EventStreamInstrumentation", - "kamon.instrumentation.akka.instrumentations.ActorRefInstrumentation" + "kamon.instrumentation.akka.instrumentations.ActorRefInstrumentation", + "kamon.instrumentation.akka.instrumentations.akka_25.DispatcherInstrumentation" + "kamon.instrumentation.akka.instrumentations.akka_26.DispatcherInstrumentation" ] within = [ @@ -158,8 +159,9 @@ kanela.modules { instrumentations = [ "kamon.instrumentation.akka.remote.MessageBufferInstrumentation", - "kamon.instrumentation.akka.remote.RemotingInstrumentation", - "kamon.instrumentation.akka.remote.ShardingInstrumentation" + "kamon.instrumentation.akka.remote.ShardingInstrumentation", + "kamon.instrumentation.akka.instrumentations.akka_25.remote.RemotingInstrumentation" + "kamon.instrumentation.akka.instrumentations.akka_26.remote.RemotingInstrumentation" ] within = [ diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/AkkaClusterShardingMetrics.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/AkkaClusterShardingMetrics.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/AkkaClusterShardingMetrics.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/AkkaClusterShardingMetrics.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/AkkaInstrumentation.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/AkkaInstrumentation.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/AkkaInstrumentation.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/AkkaInstrumentation.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/AkkaMetrics.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/AkkaMetrics.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/AkkaMetrics.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/AkkaMetrics.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/AkkaRemoteInstrumentation.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/AkkaRemoteInstrumentation.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/AkkaRemoteInstrumentation.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/AkkaRemoteInstrumentation.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/AkkaRemoteMetrics.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/AkkaRemoteMetrics.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/AkkaRemoteMetrics.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/AkkaRemoteMetrics.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorCellInfo.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorCellInfo.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorCellInfo.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorCellInfo.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorInstrumentation.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorInstrumentation.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorInstrumentation.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorInstrumentation.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorLoggingInstrumentation.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorLoggingInstrumentation.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorLoggingInstrumentation.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorLoggingInstrumentation.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorMonitor.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorMonitor.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorMonitor.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorMonitor.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorRefInstrumentation.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorRefInstrumentation.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorRefInstrumentation.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/ActorRefInstrumentation.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/AskPatternInstrumentation.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/AskPatternInstrumentation.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/AskPatternInstrumentation.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/AskPatternInstrumentation.scala diff --git a/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/DispatcherInfo.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/DispatcherInfo.scala new file mode 100644 index 0000000..2ea2444 --- /dev/null +++ b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/DispatcherInfo.scala @@ -0,0 +1,60 @@ +/* + * ========================================================================================= + * Copyright © 2013-2018 the kamon project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + * ========================================================================================= + */ + +package kamon.instrumentation.akka.instrumentations + +import java.util.concurrent.{Callable, ExecutorService} + +import akka.dispatch.{DispatcherPrerequisites, ForkJoinExecutorConfigurator, PinnedDispatcherConfigurator, ThreadPoolExecutorConfigurator} +import kamon.Kamon +import kamon.instrumentation.akka.AkkaInstrumentation +import kamon.instrumentation.akka.instrumentations.DispatcherInfo.{HasActorSystemName, HasDispatcherName} +import kamon.instrumentation.executor.ExecutorInstrumentation +import kamon.instrumentation.executor.ExecutorInstrumentation.ForkJoinPoolTelemetryReader +import kamon.tag.TagSet +import kanela.agent.api.instrumentation.InstrumentationBuilder +import kanela.agent.libs.net.bytebuddy.asm.Advice +import kanela.agent.libs.net.bytebuddy.implementation.bind.annotation.{SuperCall, This} + + +object DispatcherInfo { + + trait HasActorSystemName { + def actorSystemName: String + def setActorSystemName(actorSystemName: String): Unit + } + + object HasActorSystemName { + class Mixin extends HasActorSystemName { + @volatile private var _actorSystemName: String = _ + override def actorSystemName: String = _actorSystemName + override def setActorSystemName(actorSystemName: String): Unit = _actorSystemName = actorSystemName + } + } + + trait HasDispatcherName { + def dispatcherName: String + def setDispatcherName(dispatcherName: String): Unit + } + + object HasDispatcherName { + class Mixin extends HasDispatcherName { + @volatile private var _dispatcherName: String = _ + override def dispatcherName: String = _dispatcherName + override def setDispatcherName(dispatcherName: String): Unit = _dispatcherName = dispatcherName + } + } +} \ No newline at end of file diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/EnvelopeInstrumentation.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/EnvelopeInstrumentation.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/EnvelopeInstrumentation.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/EnvelopeInstrumentation.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/EventStreamInstrumentation.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/EventStreamInstrumentation.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/EventStreamInstrumentation.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/EventStreamInstrumentation.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/RouterInstrumentation.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/RouterInstrumentation.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/RouterInstrumentation.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/RouterInstrumentation.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/RouterMonitor.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/RouterMonitor.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/RouterMonitor.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/RouterMonitor.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/SystemMessageInstrumentation.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/SystemMessageInstrumentation.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/SystemMessageInstrumentation.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/SystemMessageInstrumentation.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/VersionFiltering.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/VersionFiltering.scala similarity index 83% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/VersionFiltering.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/VersionFiltering.scala index 76871b1..fe343db 100644 --- a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/VersionFiltering.scala +++ b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/VersionFiltering.scala @@ -16,8 +16,8 @@ trait VersionFiltering { /** * Runs the code block if a version of Akka starting with the provided version is known to be present. */ - def onAkka(version: String)(block: => Unit): Unit = { - if(akkaVersion().filter(_.startsWith(version)).nonEmpty) + def onAkka(version: String*)(block: => Unit): Unit = { + if(akkaVersion().filter(av => version.exists(v => av.startsWith(v))).isDefined) block } diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/internal/ReplaceWithMethodInterceptor.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/internal/ReplaceWithMethodInterceptor.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/instrumentations/internal/ReplaceWithMethodInterceptor.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/instrumentations/internal/ReplaceWithMethodInterceptor.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/MessageBufferInstrumentation.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/remote/MessageBufferInstrumentation.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/MessageBufferInstrumentation.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/remote/MessageBufferInstrumentation.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/ShardingInstrumentation.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/remote/ShardingInstrumentation.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/ShardingInstrumentation.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/remote/ShardingInstrumentation.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/internal/KamonOptionVal.scala b/instrumentation/common/src/main/scala/kamon/instrumentation/akka/remote/internal/KamonOptionVal.scala similarity index 100% rename from kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/internal/KamonOptionVal.scala rename to instrumentation/common/src/main/scala/kamon/instrumentation/akka/remote/internal/KamonOptionVal.scala diff --git a/kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/RemotingInstrumentation.scala b/kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/RemotingInstrumentation.scala deleted file mode 100644 index c337ae9..0000000 --- a/kamon-akka/src/main/scala/kamon/instrumentation/akka/remote/RemotingInstrumentation.scala +++ /dev/null @@ -1,129 +0,0 @@ -package kamon.instrumentation.akka.remote - -import akka.actor.ActorSystem -import akka.kamon.instrumentation.kanela.interceptor.AkkaPduProtobufCodecConstructMessageMethodInterceptor -import akka.remote.kamon.instrumentation.kanela.advisor._ -import kamon.Kamon -import kamon.context.Storage.Scope -import kamon.instrumentation.akka.AkkaRemoteInstrumentation -import kamon.instrumentation.akka.AkkaRemoteMetrics.SerializationInstruments -import kamon.instrumentation.akka.instrumentations.AkkaPrivateAccess -import kamon.instrumentation.context.{CaptureCurrentContextOnExit, HasContext} -import kanela.agent.api.instrumentation.InstrumentationBuilder -import kanela.agent.libs.net.bytebuddy.asm.Advice - - -class RemotingInstrumentation extends InstrumentationBuilder { - - /** - * Send messages might be buffered if they reach the EndpointWriter before it has been initialized and the current - * Context might be lost after the buffering, so we make sure we capture the context when the Send command was - * created and then apply it during the EndpointWrite.writeSend method execution (see bellow). - */ - onType("akka.remote.EndpointManager$Send") - .mixin(classOf[HasContext.Mixin]) - .advise(isConstructor, CaptureCurrentContextOnExit) - - onType("akka.remote.EndpointWriter") - .advise(method("writeSend"), WriteSendWithContext) - - /** - * Reads and writes the Akka PDU using a modified version of the Protobuf that has an extra field for a Context - * instance. - */ - onType("akka.remote.transport.AkkaPduProtobufCodec$") - .intercept(method("constructMessage"), new AkkaPduProtobufCodecConstructMessageMethodInterceptor()) - .advise(method("decodeMessage"), classOf[AkkaPduProtobufCodecDecodeMessage]) - - /** - * Mixin Serialization Instruments to the Actor System and use them to record the serialization and deserialization - * time metrics. - */ - onType("akka.actor.ActorSystemImpl") - .mixin(classOf[HasSerializationInstruments.Mixin]) - .advise(isConstructor, InitializeActorSystemAdvice) - - onType("akka.remote.MessageSerializer$") - .advise(method("serialize"), MeasureSerializationTime) - .advise(method("deserialize"), MeasureDeserializationTime) - -} - -object WriteSendWithContext { - - @Advice.OnMethodEnter - def enter(@Advice.Argument(0) send: Any): Scope = { - Kamon.storeContext(send.asInstanceOf[HasContext].context) - } - - @Advice.OnMethodExit - def exit(@Advice.Enter scope: Scope): Unit = { - scope.asInstanceOf[Scope].close() - } -} - -trait HasSerializationInstruments { - def serializationInstruments: SerializationInstruments - def setSerializationInstruments(instruments: SerializationInstruments): Unit -} - -object HasSerializationInstruments { - - class Mixin(var serializationInstruments: SerializationInstruments) extends HasSerializationInstruments { - override def setSerializationInstruments(instruments: SerializationInstruments): Unit = - serializationInstruments = instruments - } -} - -object InitializeActorSystemAdvice { - - @Advice.OnMethodExit - def exit(@Advice.This system: ActorSystem with HasSerializationInstruments): Unit = - system.setSerializationInstruments(new SerializationInstruments(system.name)) - -} - -object MeasureSerializationTime { - - @Advice.OnMethodEnter - def enter(): Long = { - if(AkkaRemoteInstrumentation.settings().trackSerializationMetrics) System.nanoTime() else 0L - } - - @Advice.OnMethodExit - def exit(@Advice.Argument(0) system: AnyRef, @Advice.Enter startNanoTime: Long): Unit = { - if(startNanoTime != 0L) { - system.asInstanceOf[HasSerializationInstruments] - .serializationInstruments - .serializationTime - .record(System.nanoTime() - startNanoTime) - } - } -} - -object MeasureDeserializationTime { - - @Advice.OnMethodEnter - def enter(): Long = { - if(AkkaRemoteInstrumentation.settings().trackSerializationMetrics) System.nanoTime() else 0L - } - - @Advice.OnMethodExit - def exit(@Advice.Argument(0) system: AnyRef, @Advice.Enter startNanoTime: Long, @Advice.Return msg: Any): Unit = { - - if(AkkaPrivateAccess.isSystemMessage(msg)) { - msg match { - case hc: HasContext if hc.context == null => - hc.setContext(Kamon.currentContext()) - case _ => - } - } - - if(startNanoTime != 0L) { - system.asInstanceOf[HasSerializationInstruments] - .serializationInstruments - .deserializationTime - .record(System.nanoTime() - startNanoTime) - } - } -} diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/remote/RemotingInstrumentationSpec.scala b/test/akka-2.4/src/test/scala/kamon/instrumentation/akka/remote/RemotingInstrumentationSpec.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/remote/RemotingInstrumentationSpec.scala rename to test/akka-2.4/src/test/scala/kamon/instrumentation/akka/remote/RemotingInstrumentationSpec.scala diff --git a/test/akka-2.5/src/test/scala/kamon/instrumentation/akka/remote/ArteryTcpRemotingInstrumentationSpec.scala b/test/akka-2.5/src/test/scala/kamon/instrumentation/akka/remote/ArteryTcpRemotingInstrumentationSpec.scala new file mode 100644 index 0000000..4a73176 --- /dev/null +++ b/test/akka-2.5/src/test/scala/kamon/instrumentation/akka/remote/ArteryTcpRemotingInstrumentationSpec.scala @@ -0,0 +1,162 @@ +package kamon.instrumentation.akka.remote + +import akka.actor._ +import akka.pattern.{ask, pipe} +import akka.routing.RoundRobinGroup +import akka.testkit.{ImplicitSender, TestKitBase} +import akka.util.Timeout +import com.typesafe.config.ConfigFactory +import kamon.Kamon +import kamon.context.Context +import kamon.instrumentation.akka.AkkaRemoteMetrics.{DeserializationTime, SerializationTime} +import kamon.instrumentation.akka.{AkkaRemoteMetrics, ContextEchoActor} +import kamon.tag.TagSet +import kamon.testkit.{InstrumentInspection, MetricInspection} +import org.scalatest.Inspectors._ +import org.scalatest.{Matchers, WordSpecLike} + +import scala.concurrent.duration._ + +class ArteryTcpRemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Matchers with ImplicitSender + with MetricInspection.Syntax with InstrumentInspection.Syntax { + + implicit lazy val system: ActorSystem = { + ActorSystem("remoting-spec-local-system", ConfigFactory.parseString( + """ + |akka { + | actor { + | provider = cluster + | } + | + | remote { + | artery { + | enabled = on + | transport = tcp + | canonical.hostname = "127.0.0.1" + | canonical.port = 2554 + | } + | } + |} + """.stripMargin)) + } + + val remoteSystem: ActorSystem = ActorSystem("remoting-spec-remote-system", ConfigFactory.parseString( + """ + |akka { + | actor { + | provider = cluster + | } + | + | remote { + | artery { + | enabled = on + | transport = tcp + | canonical.hostname = "127.0.0.1" + | canonical.port = 2555 + | } + | } + |} + """.stripMargin)) + + val RemoteSystemAddress = AddressFromURIString("akka://remoting-spec-remote-system@127.0.0.1:2555") + + def contextWithBroadcast(name: String): Context = + Context.Empty.withTag( + ContextEchoActor.EchoTag, + name + ) + + "The Akka Remote instrumentation" should { + "propagate the current Context when creating a new remote actor" in { + val a = Kamon.runWithContext(contextWithBroadcast("deploy-remote-actor-1")) { + system.actorOf(ContextEchoActor.remoteProps(Some(testActor), RemoteSystemAddress), "remote-deploy-fixture") + } + + expectMsg(10 seconds, "name=deploy-remote-actor-1") + } + + + "propagate the Context when sending a message to a remotely deployed actor" in { + val remoteRef = system.actorOf(ContextEchoActor.remoteProps(None, RemoteSystemAddress), "remote-message-fixture") + + Kamon.runWithContext(contextWithBroadcast("message-remote-actor-1")) { + remoteRef ! "reply-trace-token" + } + expectMsg("name=message-remote-actor-1") + } + + + "propagate the current Context when pipe or ask a message to a remotely deployed actor" in { + implicit val ec = system.dispatcher + implicit val askTimeout = Timeout(10 seconds) + val remoteRef = system.actorOf(ContextEchoActor.remoteProps(None, RemoteSystemAddress), "remote-ask-and-pipe-fixture") + + Kamon.runWithContext(contextWithBroadcast("ask-and-pipe-remote-actor-1")) { + (remoteRef ? "reply-trace-token") pipeTo testActor + } + + expectMsg("name=ask-and-pipe-remote-actor-1") + } + + + "propagate the current Context when sending a message to an ActorSelection" in { + remoteSystem.actorOf(ContextEchoActor.props(None), "actor-selection-target-a") + remoteSystem.actorOf(ContextEchoActor.props(None), "actor-selection-target-b") + val selection = system.actorSelection(RemoteSystemAddress + "/user/actor-selection-target-*") + + Kamon.runWithContext(contextWithBroadcast("message-remote-actor-selection-1")) { + selection ! "reply-trace-token" + } + + // one for each selected actor + expectMsg("name=message-remote-actor-selection-1") + expectMsg("name=message-remote-actor-selection-1") + } + + "propagate the current Context when sending messages to remote routees of a router" in { + remoteSystem.actorOf(ContextEchoActor.props(None), "router-target-a") + remoteSystem.actorOf(ContextEchoActor.props(None), "router-target-b") + val router = system.actorOf(RoundRobinGroup(List( + RemoteSystemAddress + "/user/router-target-a", + RemoteSystemAddress + "/user/router-target-b" + )).props(), "router") + + Kamon.runWithContext(contextWithBroadcast("remote-routee-1")) { + router ! "reply-trace-token" + } + + expectMsg("name=remote-routee-1") + } + + "propagate the current Context when a remotely supervised child fails" in { + val supervisor = system.actorOf(Props(new SupervisorOfRemote(testActor, RemoteSystemAddress)),"SUPERVISOR") + + Kamon.runWithContext(contextWithBroadcast("remote-supervision-1")) { + supervisor ! "fail" + } + + expectMsg(2 minutes,"name=remote-supervision-1") + } + + "record in/out message counts and sizes for both sending and receiving side" in { + val (out, in) = ( + AkkaRemoteMetrics.OutboundMessageSize.withTags(TagSet.of("system", system.name)).distribution(false), + AkkaRemoteMetrics.OutboundMessageSize.withTags(TagSet.of("system", system.name)).distribution(false) + ) + + assert(out.max > 0) + assert(in.max > 0) + assert(out.count > 0) + assert(in.count > 0) + } + + "record de/serialization times for messages" in { + val systems = Seq(system.name, remoteSystem.name) + val serializationTimes = systems.map(s => SerializationTime.withTags(TagSet.of("system", s)).distribution().count) + val deserializationTimes = systems.map(s => DeserializationTime.withTags(TagSet.of("system", s)).distribution().count) + + forAll(serializationTimes ++ deserializationTimes) { count => assert(count > 0) } + } + } +} + diff --git a/test/akka-2.5/src/test/scala/kamon/instrumentation/akka/remote/RemotingInstrumentationSpec.scala b/test/akka-2.5/src/test/scala/kamon/instrumentation/akka/remote/RemotingInstrumentationSpec.scala new file mode 100644 index 0000000..00ad58a --- /dev/null +++ b/test/akka-2.5/src/test/scala/kamon/instrumentation/akka/remote/RemotingInstrumentationSpec.scala @@ -0,0 +1,181 @@ +package kamon.instrumentation.akka.remote + +import akka.actor.SupervisorStrategy.Resume +import akka.actor._ +import akka.pattern.{ask, pipe} +import akka.routing.RoundRobinGroup +import akka.testkit.{ImplicitSender, TestKitBase} +import akka.util.Timeout +import com.typesafe.config.ConfigFactory +import kamon.Kamon +import kamon.context.Context +import kamon.instrumentation.akka.AkkaRemoteMetrics.{DeserializationTime, SerializationTime} +import kamon.instrumentation.akka.{AkkaRemoteMetrics, ContextEchoActor} +import kamon.tag.Lookups._ +import kamon.tag.TagSet +import kamon.testkit.{InstrumentInspection, MetricInspection} +import org.scalatest.Inspectors._ +import org.scalatest.{Matchers, WordSpecLike} + +import scala.concurrent.duration._ +import scala.util.control.NonFatal + +class RemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Matchers with ImplicitSender + with MetricInspection.Syntax with InstrumentInspection.Syntax { + + implicit lazy val system: ActorSystem = { + ActorSystem("remoting-spec-local-system", ConfigFactory.parseString( + """ + |akka { + | actor { + | provider = "akka.remote.RemoteActorRefProvider" + | } + | remote { + | enabled-transports = ["akka.remote.netty.tcp"] + | netty.tcp { + | hostname = "127.0.0.1" + | port = 2552 + | } + | } + |} + """.stripMargin)) + } + + val remoteSystem: ActorSystem = ActorSystem("remoting-spec-remote-system", ConfigFactory.parseString( + """ + |akka { + | actor { + | provider = "akka.remote.RemoteActorRefProvider" + | } + | remote { + | enabled-transports = ["akka.remote.netty.tcp"] + | netty.tcp { + | hostname = "127.0.0.1" + | port = 2553 + | } + | } + |} + """.stripMargin)) + + val RemoteSystemAddress = AddressFromURIString("akka.tcp://remoting-spec-remote-system@127.0.0.1:2553") + + def contextWithBroadcast(name: String): Context = + Context.Empty.withTag( + ContextEchoActor.EchoTag, + name + ) + + "The Akka Remote instrumentation" should { + "propagate the current Context when creating a new remote actor" in { + val a = Kamon.runWithContext(contextWithBroadcast("deploy-remote-actor-1")) { + system.actorOf(ContextEchoActor.remoteProps(Some(testActor), RemoteSystemAddress), "remote-deploy-fixture") + } + + expectMsg(10 seconds, "name=deploy-remote-actor-1") + } + + + "propagate the Context when sending a message to a remotely deployed actor" in { + val remoteRef = system.actorOf(ContextEchoActor.remoteProps(None, RemoteSystemAddress), "remote-message-fixture") + + Kamon.runWithContext(contextWithBroadcast("message-remote-actor-1")) { + remoteRef ! "reply-trace-token" + } + expectMsg("name=message-remote-actor-1") + } + + + "propagate the current Context when pipe or ask a message to a remotely deployed actor" in { + implicit val ec = system.dispatcher + implicit val askTimeout = Timeout(10 seconds) + val remoteRef = system.actorOf(ContextEchoActor.remoteProps(None, RemoteSystemAddress), "remote-ask-and-pipe-fixture") + + Kamon.runWithContext(contextWithBroadcast("ask-and-pipe-remote-actor-1")) { + (remoteRef ? "reply-trace-token") pipeTo testActor + } + + expectMsg("name=ask-and-pipe-remote-actor-1") + } + + + "propagate the current Context when sending a message to an ActorSelection" in { + remoteSystem.actorOf(ContextEchoActor.props(None), "actor-selection-target-a") + remoteSystem.actorOf(ContextEchoActor.props(None), "actor-selection-target-b") + val selection = system.actorSelection(RemoteSystemAddress + "/user/actor-selection-target-*") + + Kamon.runWithContext(contextWithBroadcast("message-remote-actor-selection-1")) { + selection ! "reply-trace-token" + } + + // one for each selected actor + expectMsg("name=message-remote-actor-selection-1") + expectMsg("name=message-remote-actor-selection-1") + } + + "propagate the current Context when sending messages to remote routees of a router" in { + remoteSystem.actorOf(ContextEchoActor.props(None), "router-target-a") + remoteSystem.actorOf(ContextEchoActor.props(None), "router-target-b") + val router = system.actorOf(RoundRobinGroup(List( + RemoteSystemAddress + "/user/router-target-a", + RemoteSystemAddress + "/user/router-target-b" + )).props(), "router") + + Kamon.runWithContext(contextWithBroadcast("remote-routee-1")) { + router ! "reply-trace-token" + } + + expectMsg("name=remote-routee-1") + } + + "propagate the current Context when a remotely supervised child fails" in { + val supervisor = system.actorOf(Props(new SupervisorOfRemote(testActor, RemoteSystemAddress)),"SUPERVISOR") + + Kamon.runWithContext(contextWithBroadcast("remote-supervision-1")) { + supervisor ! "fail" + } + + expectMsg(2 minutes,"name=remote-supervision-1") + } + + "record in/out message counts and sizes for both sending and receiving side" in { + val (out, in) = ( + AkkaRemoteMetrics.OutboundMessageSize.withTags(TagSet.of("system", system.name)).distribution(false), + AkkaRemoteMetrics.OutboundMessageSize.withTags(TagSet.of("system", system.name)).distribution(false) + ) + + assert(out.max > 0) + assert(in.max > 0) + assert(out.count > 0) + assert(in.count > 0) + } + + "record de/serialization times for messages" in { + val systems = Seq(system.name, remoteSystem.name) + val serializationTimes = systems.map(s => SerializationTime.withTags(TagSet.of("system", s)).distribution().count) + val deserializationTimes = systems.map(s => DeserializationTime.withTags(TagSet.of("system", s)).distribution().count) + + forAll(serializationTimes ++ deserializationTimes) { count => assert(count > 0) } + } + } +} + +class SupervisorOfRemote(echoListener: ActorRef, remoteAddress: Address) extends Actor { + val supervisedChild = context.actorOf(ContextEchoActor.remoteProps(None, remoteAddress), "remotely-supervised-child") + + def receive = { + case "fail" => supervisedChild ! "die" + } + + override def supervisorStrategy: SupervisorStrategy = OneForOneStrategy() { + case NonFatal(_) => + echoListener ! currentEchoMessage + Resume + case _ => Resume + } + + def currentEchoMessage: String = { + val ctx = Kamon.currentContext() + val name = ctx.getTag(option(ContextEchoActor.EchoTag)).getOrElse("") + s"name=$name" + } +} \ No newline at end of file diff --git a/test/akka-2.6/src/test/scala/kamon/instrumentation/akka/remote/ArteryTcpRemotingInstrumentationSpec.scala b/test/akka-2.6/src/test/scala/kamon/instrumentation/akka/remote/ArteryTcpRemotingInstrumentationSpec.scala new file mode 100644 index 0000000..7987b59 --- /dev/null +++ b/test/akka-2.6/src/test/scala/kamon/instrumentation/akka/remote/ArteryTcpRemotingInstrumentationSpec.scala @@ -0,0 +1,160 @@ +package kamon.instrumentation.akka.remote + +import akka.actor._ +import akka.pattern.{ask, pipe} +import akka.routing.RoundRobinGroup +import akka.testkit.{ImplicitSender, TestKitBase} +import akka.util.Timeout +import com.typesafe.config.ConfigFactory +import kamon.Kamon +import kamon.context.Context +import kamon.instrumentation.akka.AkkaRemoteMetrics.{DeserializationTime, SerializationTime} +import kamon.instrumentation.akka.{AkkaRemoteMetrics, ContextEchoActor} +import kamon.tag.TagSet +import kamon.testkit.{InstrumentInspection, MetricInspection} +import org.scalatest.Inspectors._ +import org.scalatest.{Matchers, WordSpecLike} + +import scala.concurrent.duration._ + +class ArteryTcpRemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Matchers with ImplicitSender + with MetricInspection.Syntax with InstrumentInspection.Syntax { + + implicit lazy val system: ActorSystem = { + ActorSystem("remoting-spec-local-system", ConfigFactory.parseString( + """ + |akka { + | actor { + | provider = cluster + | } + | + | remote { + | artery { + | transport = tcp + | canonical.hostname = "127.0.0.1" + | canonical.port = 2554 + | } + | } + |} + """.stripMargin)) + } + + val remoteSystem: ActorSystem = ActorSystem("remoting-spec-remote-system", ConfigFactory.parseString( + """ + |akka { + | actor { + | provider = cluster + | } + | + | remote { + | artery { + | transport = tcp + | canonical.hostname = "127.0.0.1" + | canonical.port = 2555 + | } + | } + |} + """.stripMargin)) + + val RemoteSystemAddress = AddressFromURIString("akka://remoting-spec-remote-system@127.0.0.1:2555") + + def contextWithNameTag(name: String): Context = + Context.Empty.withTag( + ContextEchoActor.EchoTag, + name + ) + + "The Akka Remote instrumentation" should { + "propagate the current Context when creating a new remote actor" in { + Kamon.runWithContext(contextWithNameTag("deploy-remote-actor-1")) { + system.actorOf(ContextEchoActor.remoteProps(Some(testActor), RemoteSystemAddress), "remote-deploy-fixture") + } + + expectMsg(10 seconds, "name=deploy-remote-actor-1") + } + + + "propagate the Context when sending a message to a remotely deployed actor" in { + val remoteRef = system.actorOf(ContextEchoActor.remoteProps(None, RemoteSystemAddress), "remote-message-fixture") + + Kamon.runWithContext(contextWithNameTag("message-remote-actor-1")) { + remoteRef ! "reply-trace-token" + } + expectMsg("name=message-remote-actor-1") + } + + + "propagate the current Context when pipe or ask a message to a remotely deployed actor" in { + implicit val ec = system.dispatcher + implicit val askTimeout = Timeout(10 seconds) + val remoteRef = system.actorOf(ContextEchoActor.remoteProps(None, RemoteSystemAddress), "remote-ask-and-pipe-fixture") + + Kamon.runWithContext(contextWithNameTag("ask-and-pipe-remote-actor-1")) { + (remoteRef ? "reply-trace-token") pipeTo testActor + } + + expectMsg("name=ask-and-pipe-remote-actor-1") + } + + + "propagate the current Context when sending a message to an ActorSelection" in { + remoteSystem.actorOf(ContextEchoActor.props(None), "actor-selection-target-a") + remoteSystem.actorOf(ContextEchoActor.props(None), "actor-selection-target-b") + val selection = system.actorSelection(RemoteSystemAddress + "/user/actor-selection-target-*") + + Kamon.runWithContext(contextWithNameTag("message-remote-actor-selection-1")) { + selection ! "reply-trace-token" + } + + // one for each selected actor + expectMsg("name=message-remote-actor-selection-1") + expectMsg("name=message-remote-actor-selection-1") + } + + "propagate the current Context when sending messages to remote routees of a router" in { + remoteSystem.actorOf(ContextEchoActor.props(None), "router-target-a") + remoteSystem.actorOf(ContextEchoActor.props(None), "router-target-b") + val router = system.actorOf(RoundRobinGroup(List( + RemoteSystemAddress + "/user/router-target-a", + RemoteSystemAddress + "/user/router-target-b" + )).props(), "router") + + Kamon.runWithContext(contextWithNameTag("remote-routee-1")) { + router ! "reply-trace-token" + } + + expectMsg("name=remote-routee-1") + } + + "propagate the current Context when a remotely supervised child fails" in { + val supervisor = system.actorOf(Props(new SupervisorOfRemote(testActor, RemoteSystemAddress)),"SUPERVISOR") + + Kamon.runWithContext(contextWithNameTag("remote-supervision-1")) { + supervisor ! "fail" + } + + expectMsg(2 minutes,"name=remote-supervision-1") + } + + "record in/out message counts and sizes for both sending and receiving side" in { + val (out, in) = ( + AkkaRemoteMetrics.OutboundMessageSize.withTags(TagSet.of("system", system.name)).distribution(false), + AkkaRemoteMetrics.OutboundMessageSize.withTags(TagSet.of("system", system.name)).distribution(false) + ) + + assert(out.max > 0) + assert(in.max > 0) + assert(out.count > 0) + assert(in.count > 0) + } + + "record de/serialization times for messages" in { + val systems = Seq(system.name, remoteSystem.name) + val serializationTimes = systems.map(s => SerializationTime.withTags(TagSet.of("system", s)).distribution().count) + val deserializationTimes = systems.map(s => DeserializationTime.withTags(TagSet.of("system", s)).distribution().count) + + forAll(serializationTimes ++ deserializationTimes) { count => assert(count > 0) } + } + } +} + diff --git a/test/akka-2.6/src/test/scala/kamon/instrumentation/akka/remote/RemotingInstrumentationSpec.scala b/test/akka-2.6/src/test/scala/kamon/instrumentation/akka/remote/RemotingInstrumentationSpec.scala new file mode 100644 index 0000000..31d7034 --- /dev/null +++ b/test/akka-2.6/src/test/scala/kamon/instrumentation/akka/remote/RemotingInstrumentationSpec.scala @@ -0,0 +1,189 @@ +package kamon.instrumentation.akka.remote + +import akka.actor.SupervisorStrategy.Resume +import akka.actor._ +import akka.pattern.{ask, pipe} +import akka.routing.RoundRobinGroup +import akka.testkit.{ImplicitSender, TestKitBase} +import akka.util.Timeout +import com.typesafe.config.ConfigFactory +import kamon.Kamon +import kamon.context.Context +import kamon.instrumentation.akka.AkkaRemoteMetrics.{DeserializationTime, SerializationTime} +import kamon.instrumentation.akka.{AkkaRemoteMetrics, ContextEchoActor} +import kamon.tag.Lookups._ +import kamon.tag.TagSet +import kamon.testkit.{InstrumentInspection, MetricInspection} +import org.scalatest.Inspectors._ +import org.scalatest.{Matchers, WordSpecLike} + +import scala.concurrent.duration._ +import scala.util.control.NonFatal + +class RemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Matchers with ImplicitSender + with MetricInspection.Syntax with InstrumentInspection.Syntax { + + implicit lazy val system: ActorSystem = { + ActorSystem("remoting-spec-local-system", ConfigFactory.parseString( + """ + |akka { + | actor { + | provider = "akka.remote.RemoteActorRefProvider" + | } + | remote { + | artery.enabled = false + | + | classic { + | enabled-transports = ["akka.remote.classic.netty.tcp"] + | netty.tcp { + | hostname = "127.0.0.1" + | port = 2552 + | } + | } + | } + |} + """.stripMargin)) + } + + val remoteSystem: ActorSystem = ActorSystem("remoting-spec-remote-system", ConfigFactory.parseString( + """ + |akka { + | actor { + | provider = "akka.remote.RemoteActorRefProvider" + | } + | remote { + | artery.enabled = false + | + | classic { + | enabled-transports = ["akka.remote.classic.netty.tcp"] + | netty.tcp { + | hostname = "127.0.0.1" + | port = 2553 + | } + | } + | } + |} + """.stripMargin)) + + val RemoteSystemAddress = AddressFromURIString("akka.tcp://remoting-spec-remote-system@127.0.0.1:2553") + + def contextWithBroadcast(name: String): Context = + Context.Empty.withTag( + ContextEchoActor.EchoTag, + name + ) + + "The Akka Remote instrumentation" should { + "propagate the current Context when creating a new remote actor" in { + val a = Kamon.runWithContext(contextWithBroadcast("deploy-remote-actor-1")) { + system.actorOf(ContextEchoActor.remoteProps(Some(testActor), RemoteSystemAddress), "remote-deploy-fixture") + } + + expectMsg(10 seconds, "name=deploy-remote-actor-1") + } + + + "propagate the Context when sending a message to a remotely deployed actor" in { + val remoteRef = system.actorOf(ContextEchoActor.remoteProps(None, RemoteSystemAddress), "remote-message-fixture") + + Kamon.runWithContext(contextWithBroadcast("message-remote-actor-1")) { + remoteRef ! "reply-trace-token" + } + expectMsg("name=message-remote-actor-1") + } + + + "propagate the current Context when pipe or ask a message to a remotely deployed actor" in { + implicit val ec = system.dispatcher + implicit val askTimeout = Timeout(10 seconds) + val remoteRef = system.actorOf(ContextEchoActor.remoteProps(None, RemoteSystemAddress), "remote-ask-and-pipe-fixture") + + Kamon.runWithContext(contextWithBroadcast("ask-and-pipe-remote-actor-1")) { + (remoteRef ? "reply-trace-token") pipeTo testActor + } + + expectMsg("name=ask-and-pipe-remote-actor-1") + } + + + "propagate the current Context when sending a message to an ActorSelection" in { + remoteSystem.actorOf(ContextEchoActor.props(None), "actor-selection-target-a") + remoteSystem.actorOf(ContextEchoActor.props(None), "actor-selection-target-b") + val selection = system.actorSelection(RemoteSystemAddress + "/user/actor-selection-target-*") + + Kamon.runWithContext(contextWithBroadcast("message-remote-actor-selection-1")) { + selection ! "reply-trace-token" + } + + // one for each selected actor + expectMsg("name=message-remote-actor-selection-1") + expectMsg("name=message-remote-actor-selection-1") + } + + "propagate the current Context when sending messages to remote routees of a router" in { + remoteSystem.actorOf(ContextEchoActor.props(None), "router-target-a") + remoteSystem.actorOf(ContextEchoActor.props(None), "router-target-b") + val router = system.actorOf(RoundRobinGroup(List( + RemoteSystemAddress + "/user/router-target-a", + RemoteSystemAddress + "/user/router-target-b" + )).props(), "router") + + Kamon.runWithContext(contextWithBroadcast("remote-routee-1")) { + router ! "reply-trace-token" + } + + expectMsg("name=remote-routee-1") + } + + "propagate the current Context when a remotely supervised child fails" in { + val supervisor = system.actorOf(Props(new SupervisorOfRemote(testActor, RemoteSystemAddress)),"SUPERVISOR") + + Kamon.runWithContext(contextWithBroadcast("remote-supervision-1")) { + supervisor ! "fail" + } + + expectMsg(2 minutes,"name=remote-supervision-1") + } + + "record in/out message counts and sizes for both sending and receiving side" in { + val (out, in) = ( + AkkaRemoteMetrics.OutboundMessageSize.withTags(TagSet.of("system", system.name)).distribution(false), + AkkaRemoteMetrics.OutboundMessageSize.withTags(TagSet.of("system", system.name)).distribution(false) + ) + + assert(out.max > 0) + assert(in.max > 0) + assert(out.count > 0) + assert(in.count > 0) + } + + "record de/serialization times for messages" in { + val systems = Seq(system.name, remoteSystem.name) + val serializationTimes = systems.map(s => SerializationTime.withTags(TagSet.of("system", s)).distribution().count) + val deserializationTimes = systems.map(s => DeserializationTime.withTags(TagSet.of("system", s)).distribution().count) + + forAll(serializationTimes ++ deserializationTimes) { count => assert(count > 0) } + } + } +} + +class SupervisorOfRemote(echoListener: ActorRef, remoteAddress: Address) extends Actor { + val supervisedChild = context.actorOf(ContextEchoActor.remoteProps(None, remoteAddress), "remotely-supervised-child") + + def receive = { + case "fail" => supervisedChild ! "die" + } + + override def supervisorStrategy: SupervisorStrategy = OneForOneStrategy() { + case NonFatal(_) => + echoListener ! currentEchoMessage + Resume + case _ => Resume + } + + def currentEchoMessage: String = { + val ctx = Kamon.currentContext() + val name = ctx.getTag(option(ContextEchoActor.EchoTag)).getOrElse("") + s"name=$name" + } +} \ No newline at end of file diff --git a/kamon-akka-common-tests/src/test/resources/application.conf b/test/common/src/test/resources/application.conf similarity index 100% rename from kamon-akka-common-tests/src/test/resources/application.conf rename to test/common/src/test/resources/application.conf diff --git a/kamon-akka-common-tests/src/test/resources/logback.xml b/test/common/src/test/resources/logback.xml similarity index 100% rename from kamon-akka-common-tests/src/test/resources/logback.xml rename to test/common/src/test/resources/logback.xml diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ActorCellInstrumentationSpec.scala b/test/common/src/test/scala/kamon/instrumentation/akka/ActorCellInstrumentationSpec.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ActorCellInstrumentationSpec.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/ActorCellInstrumentationSpec.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ActorGroupMetricsSpec.scala b/test/common/src/test/scala/kamon/instrumentation/akka/ActorGroupMetricsSpec.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ActorGroupMetricsSpec.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/ActorGroupMetricsSpec.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ActorLoggingInstrumentationSpec.scala b/test/common/src/test/scala/kamon/instrumentation/akka/ActorLoggingInstrumentationSpec.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ActorLoggingInstrumentationSpec.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/ActorLoggingInstrumentationSpec.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ActorMetricsSpec.scala b/test/common/src/test/scala/kamon/instrumentation/akka/ActorMetricsSpec.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ActorMetricsSpec.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/ActorMetricsSpec.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ActorMetricsTestActor.scala b/test/common/src/test/scala/kamon/instrumentation/akka/ActorMetricsTestActor.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ActorMetricsTestActor.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/ActorMetricsTestActor.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ActorSystemMetricsSpec.scala b/test/common/src/test/scala/kamon/instrumentation/akka/ActorSystemMetricsSpec.scala similarity index 89% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ActorSystemMetricsSpec.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/ActorSystemMetricsSpec.scala index 77cc651..f80914b 100644 --- a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ActorSystemMetricsSpec.scala +++ b/test/common/src/test/scala/kamon/instrumentation/akka/ActorSystemMetricsSpec.scala @@ -15,6 +15,7 @@ package kamon.instrumentation.akka +import akka.Version import akka.actor._ import akka.testkit.{ImplicitSender, TestKit, TestProbe} import kamon.instrumentation.akka.ActorMetricsTestActor._ @@ -29,6 +30,8 @@ import scala.concurrent.duration._ class ActorSystemMetricsSpec extends TestKit(ActorSystem("ActorSystemMetricsSpec")) with WordSpecLike with MetricInspection.Syntax with InstrumentInspection.Syntax with Matchers with BeforeAndAfterAll with ImplicitSender with Eventually { + // Akka 2.6 creates two more actors by default for the streams materializers supervisor. + val baseActorCount = if(Version.current.startsWith("2.6")) 8L else 6L val systemMetrics = AkkaMetrics.forSystem(system.name) "the Actor System metrics" should { @@ -38,8 +41,8 @@ class ActorSystemMetricsSpec extends TestKit(ActorSystem("ActorSystemMetricsSpec // This establishes a baseline on actor counts for the rest of the test. activeActors.count should be > 0L - activeActors.min shouldBe 6L - activeActors.max shouldBe 6L + activeActors.min shouldBe baseActorCount + activeActors.max shouldBe baseActorCount } val actors = (1 to 10).map(id => watch(system.actorOf(Props[ActorMetricsTestActor], s"just-some-actor-$id"))) @@ -53,8 +56,8 @@ class ActorSystemMetricsSpec extends TestKit(ActorSystem("ActorSystemMetricsSpec eventually(timeout(5 seconds)) { val activeActors = systemMetrics.activeActors.distribution() activeActors.count should be > 0L - activeActors.min shouldBe 27L - activeActors.max shouldBe 27L + activeActors.min shouldBe 21L + baseActorCount + activeActors.max shouldBe 21L + baseActorCount } actors.foreach(system.stop) @@ -63,8 +66,8 @@ class ActorSystemMetricsSpec extends TestKit(ActorSystem("ActorSystemMetricsSpec eventually(timeout(5 seconds)) { val activeActors = systemMetrics.activeActors.distribution() activeActors.count should be > 0L - activeActors.min shouldBe 6L - activeActors.max shouldBe 6L + activeActors.min shouldBe baseActorCount + activeActors.max shouldBe baseActorCount } } diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/AkkaTestKitInstrumentation.scala b/test/common/src/test/scala/kamon/instrumentation/akka/AkkaTestKitInstrumentation.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/AkkaTestKitInstrumentation.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/AkkaTestKitInstrumentation.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/AskPatternInstrumentationSpec.scala b/test/common/src/test/scala/kamon/instrumentation/akka/AskPatternInstrumentationSpec.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/AskPatternInstrumentationSpec.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/AskPatternInstrumentationSpec.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/AutoGroupingSpec.scala b/test/common/src/test/scala/kamon/instrumentation/akka/AutoGroupingSpec.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/AutoGroupingSpec.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/AutoGroupingSpec.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ContextEchoActor.scala b/test/common/src/test/scala/kamon/instrumentation/akka/ContextEchoActor.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ContextEchoActor.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/ContextEchoActor.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ContextTesting.scala b/test/common/src/test/scala/kamon/instrumentation/akka/ContextTesting.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/ContextTesting.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/ContextTesting.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/DispatcherMetricsSpec.scala b/test/common/src/test/scala/kamon/instrumentation/akka/DispatcherMetricsSpec.scala similarity index 96% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/DispatcherMetricsSpec.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/DispatcherMetricsSpec.scala index 7dbc785..0439f82 100644 --- a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/DispatcherMetricsSpec.scala +++ b/test/common/src/test/scala/kamon/instrumentation/akka/DispatcherMetricsSpec.scala @@ -25,18 +25,21 @@ import kamon.testkit.MetricInspection import org.scalatest.concurrent.Eventually import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} import RouterMetricsTestActor._ +import akka.Version + import scala.concurrent.Future class DispatcherMetricsSpec extends TestKit(ActorSystem("DispatcherMetricsSpec")) with WordSpecLike with MetricInspection.Syntax with Matchers with BeforeAndAfterAll with ImplicitSender with Eventually { "the Kamon dispatcher metrics" should { + val trackedDispatchers = Seq( "akka.actor.default-dispatcher", "tracked-pinned-dispatcher", "tracked-fjp", "tracked-tpe" - ) + ) ++ (if(Version.current.startsWith("2.6")) Seq("akka.actor.internal-dispatcher") else Seq.empty) val excluded = "explicitly-excluded" val allDispatchers = trackedDispatchers :+ excluded diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/EnvelopeSpec.scala b/test/common/src/test/scala/kamon/instrumentation/akka/EnvelopeSpec.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/EnvelopeSpec.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/EnvelopeSpec.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/MessageTracingSpec.scala b/test/common/src/test/scala/kamon/instrumentation/akka/MessageTracingSpec.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/MessageTracingSpec.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/MessageTracingSpec.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/RouterMetricsSpec.scala b/test/common/src/test/scala/kamon/instrumentation/akka/RouterMetricsSpec.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/RouterMetricsSpec.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/RouterMetricsSpec.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/RouterMetricsTestActor.scala b/test/common/src/test/scala/kamon/instrumentation/akka/RouterMetricsTestActor.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/RouterMetricsTestActor.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/RouterMetricsTestActor.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/SystemMessageInstrumentationSpec.scala b/test/common/src/test/scala/kamon/instrumentation/akka/SystemMessageInstrumentationSpec.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/SystemMessageInstrumentationSpec.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/SystemMessageInstrumentationSpec.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/remote/MessageBufferTest.scala b/test/common/src/test/scala/kamon/instrumentation/akka/remote/MessageBufferTest.scala similarity index 100% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/remote/MessageBufferTest.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/remote/MessageBufferTest.scala diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/sharding/ShardingInstrumentationSpec.scala b/test/common/src/test/scala/kamon/instrumentation/akka/sharding/ShardingInstrumentationSpec.scala similarity index 99% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/sharding/ShardingInstrumentationSpec.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/sharding/ShardingInstrumentationSpec.scala index 958f387..b644b4d 100644 --- a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/sharding/ShardingInstrumentationSpec.scala +++ b/test/common/src/test/scala/kamon/instrumentation/akka/sharding/ShardingInstrumentationSpec.scala @@ -130,7 +130,7 @@ class ShardingInstrumentationSpec region ! HandOff("s1") expectMsg(ShardStopped("s1")) - eventually(timeout(Span(2, Seconds))) { + eventually(timeout(Span(10, Seconds))) { RegionHostedShards.withTags(shardTags).distribution().max shouldBe 0L RegionHostedEntities.withTags(shardTags).distribution().max shouldBe 0L } diff --git a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/sharding/ShardingMessageBufferingSpec.scala b/test/common/src/test/scala/kamon/instrumentation/akka/sharding/ShardingMessageBufferingSpec.scala similarity index 98% rename from kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/sharding/ShardingMessageBufferingSpec.scala rename to test/common/src/test/scala/kamon/instrumentation/akka/sharding/ShardingMessageBufferingSpec.scala index 5c58d2b..f3e7fd1 100644 --- a/kamon-akka-common-tests/src/test/scala/kamon/instrumentation/akka/sharding/ShardingMessageBufferingSpec.scala +++ b/test/common/src/test/scala/kamon/instrumentation/akka/sharding/ShardingMessageBufferingSpec.scala @@ -28,7 +28,7 @@ class ShardingMessageBufferingSpec extends TestKitBase with WordSpecLike with Ma | enabled-transports = ["akka.remote.netty.tcp"] | netty.tcp { | hostname = "127.0.0.1" - | port = 2554 + | port = 2556 | } | } |} @@ -48,7 +48,7 @@ class ShardingMessageBufferingSpec extends TestKitBase with WordSpecLike with Ma | enabled-transports = ["akka.remote.netty.tcp"] | netty.tcp { | hostname = "127.0.0.1" - | port = 2555 + | port = 2557 | } | } |}