aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/kamon/instrumentation/ExecutorServiceMetrics.scala
diff options
context:
space:
mode:
authorIvan Topolnak <ivantopo@gmail.com>2013-07-10 18:13:49 -0300
committerIvan Topolnak <ivantopo@gmail.com>2013-07-10 18:13:49 -0300
commite8dd6c83986f1ecd2d717c39bffe900b23b68854 (patch)
tree43e0feaa42225a3770922a9366e126590225719a /src/main/scala/kamon/instrumentation/ExecutorServiceMetrics.scala
parentd1e22b3f446c89413c67421f19ab5215ebdfcd43 (diff)
downloadKamon-e8dd6c83986f1ecd2d717c39bffe900b23b68854.tar.gz
Kamon-e8dd6c83986f1ecd2d717c39bffe900b23b68854.tar.bz2
Kamon-e8dd6c83986f1ecd2d717c39bffe900b23b68854.zip
complete disaster, wip
Diffstat (limited to 'src/main/scala/kamon/instrumentation/ExecutorServiceMetrics.scala')
-rw-r--r--src/main/scala/kamon/instrumentation/ExecutorServiceMetrics.scala90
1 files changed, 84 insertions, 6 deletions
diff --git a/src/main/scala/kamon/instrumentation/ExecutorServiceMetrics.scala b/src/main/scala/kamon/instrumentation/ExecutorServiceMetrics.scala
index f3ee4ee7..3ace3e77 100644
--- a/src/main/scala/kamon/instrumentation/ExecutorServiceMetrics.scala
+++ b/src/main/scala/kamon/instrumentation/ExecutorServiceMetrics.scala
@@ -8,6 +8,47 @@ import kamon.metric.{MetricDirectory, ExecutorServiceMetricCollector}
import akka.dispatch.{MonitorableThreadFactory, ExecutorServiceFactory}
+/**
+ * ExecutorService monitoring base:
+ */
+trait ExecutorServiceCollector {
+ def updateActiveThreadCount(diff: Int): Unit
+ def updateTotalThreadCount(diff: Int): Unit
+ def updateQueueSize(diff: Int): Unit
+}
+
+trait WatchedExecutorService {
+ def collector: ExecutorServiceCollector
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
case class NamedExecutorServiceFactoryDelegate(actorSystemName: String, dispatcherName: String, delegate: ExecutorServiceFactory) extends ExecutorServiceFactory {
def createExecutorService: ExecutorService = delegate.createExecutorService
}
@@ -15,11 +56,13 @@ case class NamedExecutorServiceFactoryDelegate(actorSystemName: String, dispatch
@Aspect
class ExecutorServiceFactoryProviderInstrumentation {
- @Pointcut("execution(* akka.dispatch.ExecutorServiceFactoryProvider+.createExecutorServiceFactory(..)) && args(id, threadFactory)")
- def factoryMethodCall(id: String, threadFactory: ThreadFactory) = {}
+ @Pointcut("execution(* akka.dispatch.ExecutorServiceFactoryProvider+.createExecutorServiceFactory(..)) && args(dispatcherName, threadFactory) && if()")
+ def factoryMethodCall(dispatcherName: String, threadFactory: ThreadFactory): Boolean = {
+ true
+ }
- @Around("factoryMethodCall(id, threadFactory)")
- def enrichFactoryCreationWithNames(pjp: ProceedingJoinPoint, id: String, threadFactory: ThreadFactory): ExecutorServiceFactory = {
+ @Around("factoryMethodCall(dispatcherName, threadFactory)")
+ def enrichFactoryCreationWithNames(pjp: ProceedingJoinPoint, dispatcherName: String, threadFactory: ThreadFactory): ExecutorServiceFactory = {
val delegate = pjp.proceed().asInstanceOf[ExecutorServiceFactory] // Safe Cast
val actorSystemName = threadFactory match {
@@ -27,7 +70,7 @@ class ExecutorServiceFactoryProviderInstrumentation {
case _ => "Unknown" // Find an alternative way to find the actor system name in case we start seeing "Unknown" as the AS name.
}
- new NamedExecutorServiceFactoryDelegate(actorSystemName, id, delegate)
+ new NamedExecutorServiceFactoryDelegate(actorSystemName, dispatcherName, delegate)
}
}
@@ -67,4 +110,39 @@ case class NamedExecutorServiceDelegate(fullName: String, delegate: ExecutorServ
def invokeAny[T](tasks: util.Collection[_ <: Callable[T]]): T = delegate.invokeAny(tasks)
def invokeAny[T](tasks: util.Collection[_ <: Callable[T]], timeout: Long, unit: TimeUnit): T = delegate.invokeAny(tasks, timeout, unit)
def execute(command: Runnable) = delegate.execute(command)
-} \ No newline at end of file
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+