aboutsummaryrefslogtreecommitdiff
path: root/kamon-akka
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2015-03-05 23:39:44 +0100
committerIvan Topolnjak <ivantopo@gmail.com>2015-03-09 23:09:08 +0100
commit959ce3573253ec4ac5b837d8a9c9e70f1f80bd6b (patch)
tree27c1fe8f22429fe3820f988ab17caaf8e4a6fa3a /kamon-akka
parent69ea63923e0d3697f8ca4c7eb9cb808821832aa2 (diff)
downloadKamon-959ce3573253ec4ac5b837d8a9c9e70f1f80bd6b.tar.gz
Kamon-959ce3573253ec4ac5b837d8a9c9e70f1f80bd6b.tar.bz2
Kamon-959ce3573253ec4ac5b837d8a9c9e70f1f80bd6b.zip
! all: introduced support for metric tags.
Diffstat (limited to 'kamon-akka')
-rw-r--r--kamon-akka/src/main/scala/kamon/akka/instrumentation/ActorCellInstrumentation.scala21
-rw-r--r--kamon-akka/src/main/scala/kamon/akka/instrumentation/DispatcherInstrumentation.scala12
-rw-r--r--kamon-akka/src/test/scala/kamon/akka/ActorMetricsSpec.scala4
-rw-r--r--kamon-akka/src/test/scala/kamon/akka/DispatcherMetricsSpec.scala1
-rw-r--r--kamon-akka/src/test/scala/kamon/akka/RouterMetricsSpec.scala6
-rw-r--r--kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorLoggingInstrumentationSpec.scala2
-rw-r--r--kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorSystemMessageInstrumentationSpec.scala2
-rw-r--r--kamon-akka/src/test/scala/kamon/akka/instrumentation/AskPatternInstrumentationSpec.scala2
8 files changed, 30 insertions, 20 deletions
diff --git a/kamon-akka/src/main/scala/kamon/akka/instrumentation/ActorCellInstrumentation.scala b/kamon-akka/src/main/scala/kamon/akka/instrumentation/ActorCellInstrumentation.scala
index 4783484f..d1d420fe 100644
--- a/kamon-akka/src/main/scala/kamon/akka/instrumentation/ActorCellInstrumentation.scala
+++ b/kamon-akka/src/main/scala/kamon/akka/instrumentation/ActorCellInstrumentation.scala
@@ -34,11 +34,14 @@ class ActorCellInstrumentation {
@After("actorCellCreation(cell, system, ref, props, dispatcher, parent)")
def afterCreation(cell: ActorCell, system: ActorSystem, ref: ActorRef, props: Props, dispatcher: MessageDispatcher, parent: ActorRef): Unit = {
- Kamon.metrics.register(ActorMetrics, ref.path.elements.mkString("/")).map { registration ⇒
+ val actorEntity = Entity(ref.path.elements.mkString("/"), ActorMetrics.category)
+
+ if (Kamon.metrics.shouldTrack(actorEntity)) {
+ val actorMetricsRecorder = Kamon.metrics.entity(ActorMetrics, actorEntity)
val cellMetrics = cell.asInstanceOf[ActorCellMetrics]
- cellMetrics.entity = registration.entity
- cellMetrics.recorder = Some(registration.recorder)
+ cellMetrics.entity = actorEntity
+ cellMetrics.recorder = Some(actorMetricsRecorder)
}
}
@@ -90,14 +93,14 @@ class ActorCellInstrumentation {
def afterStop(cell: ActorCell): Unit = {
val cellMetrics = cell.asInstanceOf[ActorCellMetrics]
cellMetrics.recorder.map { _ ⇒
- Kamon.metrics.unregister(cellMetrics.entity)
+ Kamon.metrics.removeEntity(cellMetrics.entity)
}
// The Stop can't be captured from the RoutedActorCell so we need to put this piece of cleanup here.
if (cell.isInstanceOf[RoutedActorCell]) {
val routedCellMetrics = cell.asInstanceOf[RoutedActorCellMetrics]
routedCellMetrics.routerRecorder.map { _ ⇒
- Kamon.metrics.unregister(routedCellMetrics.routerEntity)
+ Kamon.metrics.removeEntity(routedCellMetrics.routerEntity)
}
}
}
@@ -124,11 +127,13 @@ class RoutedActorCellInstrumentation {
@After("routedActorCellCreation(cell, system, ref, props, dispatcher, routeeProps, supervisor)")
def afterRoutedActorCellCreation(cell: RoutedActorCell, system: ActorSystem, ref: ActorRef, props: Props, dispatcher: MessageDispatcher, routeeProps: Props, supervisor: ActorRef): Unit = {
- Kamon.metrics.register(RouterMetrics, ref.path.elements.mkString("/")).map { registration ⇒
+ val routerEntity = Entity(ref.path.elements.mkString("/"), RouterMetrics.category)
+
+ if (Kamon.metrics.shouldTrack(routerEntity)) {
val cellMetrics = cell.asInstanceOf[RoutedActorCellMetrics]
- cellMetrics.routerEntity = registration.entity
- cellMetrics.routerRecorder = Some(registration.recorder)
+ cellMetrics.routerEntity = routerEntity
+ cellMetrics.routerRecorder = Some(Kamon.metrics.entity(RouterMetrics, routerEntity))
}
}
diff --git a/kamon-akka/src/main/scala/kamon/akka/instrumentation/DispatcherInstrumentation.scala b/kamon-akka/src/main/scala/kamon/akka/instrumentation/DispatcherInstrumentation.scala
index 7b15c443..eb6b5293 100644
--- a/kamon-akka/src/main/scala/kamon/akka/instrumentation/DispatcherInstrumentation.scala
+++ b/kamon-akka/src/main/scala/kamon/akka/instrumentation/DispatcherInstrumentation.scala
@@ -59,10 +59,16 @@ class DispatcherInstrumentation {
private def registerDispatcher(dispatcherName: String, executorService: ExecutorService, system: ActorSystem): Unit =
executorService match {
case fjp: AkkaForkJoinPool ⇒
- Kamon.metrics.register(ForkJoinPoolDispatcherMetrics.factory(fjp), dispatcherName)
+ val dispatcherEntity = Entity(dispatcherName, AkkaDispatcherMetrics.Category)
+
+ if (Kamon.metrics.shouldTrack(dispatcherEntity))
+ Kamon.metrics.entity(ForkJoinPoolDispatcherMetrics.factory(fjp), dispatcherName)
case tpe: ThreadPoolExecutor ⇒
- Kamon.metrics.register(ThreadPoolExecutorDispatcherMetrics.factory(tpe), dispatcherName)
+ val dispatcherEntity = Entity(dispatcherName, AkkaDispatcherMetrics.Category)
+
+ if (Kamon.metrics.shouldTrack(dispatcherEntity))
+ Kamon.metrics.entity(ThreadPoolExecutorDispatcherMetrics.factory(tpe), dispatcherName)
case others ⇒ // Currently not interested in other kinds of dispatchers.
}
@@ -120,7 +126,7 @@ class DispatcherInstrumentation {
import lazyExecutor.lookupData
if (lookupData.actorSystem != null)
- Kamon.metrics.unregister(Entity(lookupData.dispatcherName, AkkaDispatcherMetrics.Category))
+ Kamon.metrics.removeEntity(Entity(lookupData.dispatcherName, AkkaDispatcherMetrics.Category))
}
}
diff --git a/kamon-akka/src/test/scala/kamon/akka/ActorMetricsSpec.scala b/kamon-akka/src/test/scala/kamon/akka/ActorMetricsSpec.scala
index 19a71053..f4db8b8c 100644
--- a/kamon-akka/src/test/scala/kamon/akka/ActorMetricsSpec.scala
+++ b/kamon-akka/src/test/scala/kamon/akka/ActorMetricsSpec.scala
@@ -151,7 +151,7 @@ class ActorMetricsSpec extends BaseKamonSpec("actor-metrics-spec") {
trackedActor ! PoisonPill
deathWatcher.expectTerminated(trackedActor)
- actorMetricsRecorderOf(trackedActor).get shouldNot be theSameInstanceAs (firstRecorder)
+ actorMetricsRecorderOf(trackedActor) shouldBe empty
}
}
@@ -165,7 +165,7 @@ class ActorMetricsSpec extends BaseKamonSpec("actor-metrics-spec") {
def actorRecorderName(ref: ActorRef): String = ref.path.elements.mkString("/")
def actorMetricsRecorderOf(ref: ActorRef): Option[ActorMetrics] =
- Kamon.metrics.register(ActorMetrics, actorRecorderName(ref)).map(_.recorder)
+ Kamon.metrics.find(actorRecorderName(ref), ActorMetrics.category).map(_.asInstanceOf[ActorMetrics])
def collectMetricsOf(ref: ActorRef): Option[EntitySnapshot] = {
Thread.sleep(5) // Just in case the test advances a bit faster than the actor being tested.
diff --git a/kamon-akka/src/test/scala/kamon/akka/DispatcherMetricsSpec.scala b/kamon-akka/src/test/scala/kamon/akka/DispatcherMetricsSpec.scala
index 2379bff5..dd5cfa45 100644
--- a/kamon-akka/src/test/scala/kamon/akka/DispatcherMetricsSpec.scala
+++ b/kamon-akka/src/test/scala/kamon/akka/DispatcherMetricsSpec.scala
@@ -15,7 +15,6 @@
package kamon.akka
-
import akka.actor.ActorRef
import akka.dispatch.MessageDispatcher
import akka.testkit.TestProbe
diff --git a/kamon-akka/src/test/scala/kamon/akka/RouterMetricsSpec.scala b/kamon-akka/src/test/scala/kamon/akka/RouterMetricsSpec.scala
index ec55648b..41c329d6 100644
--- a/kamon-akka/src/test/scala/kamon/akka/RouterMetricsSpec.scala
+++ b/kamon-akka/src/test/scala/kamon/akka/RouterMetricsSpec.scala
@@ -180,7 +180,7 @@ class RouterMetricsSpec extends BaseKamonSpec("router-metrics-spec") {
trackedRouter ! PoisonPill
deathWatcher.expectTerminated(trackedRouter)
- routerMetricsRecorderOf("user/stop-in-pool-router").get shouldNot be theSameInstanceAs (firstRecorder)
+ routerMetricsRecorderOf("user/stop-in-pool-router") shouldBe empty
}
"clean up the associated recorder when the group router is stopped" in new RouterMetricsFixtures {
@@ -193,7 +193,7 @@ class RouterMetricsSpec extends BaseKamonSpec("router-metrics-spec") {
trackedRouter ! PoisonPill
deathWatcher.expectTerminated(trackedRouter)
- routerMetricsRecorderOf("user/stop-in-group-router").get shouldNot be theSameInstanceAs (firstRecorder)
+ routerMetricsRecorderOf("user/stop-in-group-router") shouldBe empty
}
}
@@ -205,7 +205,7 @@ class RouterMetricsSpec extends BaseKamonSpec("router-metrics-spec") {
}
def routerMetricsRecorderOf(routerName: String): Option[RouterMetrics] =
- Kamon.metrics.register(RouterMetrics, routerName).map(_.recorder)
+ Kamon.metrics.find(routerName, RouterMetrics.category).map(_.asInstanceOf[RouterMetrics])
def collectMetricsOf(routerName: String): Option[EntitySnapshot] = {
Thread.sleep(5) // Just in case the test advances a bit faster than the actor being tested.
diff --git a/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorLoggingInstrumentationSpec.scala b/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorLoggingInstrumentationSpec.scala
index 42a26cdd..85f41795 100644
--- a/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorLoggingInstrumentationSpec.scala
+++ b/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorLoggingInstrumentationSpec.scala
@@ -21,7 +21,7 @@ import com.typesafe.config.ConfigFactory
import kamon.testkit.BaseKamonSpec
import kamon.trace.TraceLocal.AvailableToMdc
import kamon.trace.logging.MdcKeysSupport
-import kamon.trace.{Tracer, TraceContextAware, TraceLocal}
+import kamon.trace.{ Tracer, TraceContextAware, TraceLocal }
import org.scalatest.Inspectors
import org.slf4j.MDC
diff --git a/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorSystemMessageInstrumentationSpec.scala b/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorSystemMessageInstrumentationSpec.scala
index fd9f58d0..1635fadc 100644
--- a/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorSystemMessageInstrumentationSpec.scala
+++ b/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorSystemMessageInstrumentationSpec.scala
@@ -21,7 +21,7 @@ import akka.actor._
import akka.testkit.ImplicitSender
import com.typesafe.config.ConfigFactory
import kamon.testkit.BaseKamonSpec
-import kamon.trace.{Tracer, EmptyTraceContext}
+import kamon.trace.{ Tracer, EmptyTraceContext }
import org.scalatest.WordSpecLike
import scala.concurrent.duration._
diff --git a/kamon-akka/src/test/scala/kamon/akka/instrumentation/AskPatternInstrumentationSpec.scala b/kamon-akka/src/test/scala/kamon/akka/instrumentation/AskPatternInstrumentationSpec.scala
index a44945ea..4268e53d 100644
--- a/kamon-akka/src/test/scala/kamon/akka/instrumentation/AskPatternInstrumentationSpec.scala
+++ b/kamon-akka/src/test/scala/kamon/akka/instrumentation/AskPatternInstrumentationSpec.scala
@@ -27,7 +27,7 @@ import com.typesafe.config.ConfigFactory
import kamon.Kamon
import kamon.akka.Akka
import kamon.testkit.BaseKamonSpec
-import kamon.trace.{Tracer, TraceContext, TraceContextAware}
+import kamon.trace.{ Tracer, TraceContext, TraceContextAware }
import scala.concurrent.duration._