From 0915ccaf0586e29b0e223c55fdb7acf23fc7264f Mon Sep 17 00:00:00 2001 From: Diego Parra Date: Tue, 26 Nov 2013 15:54:10 -0300 Subject: added scalariform --- .../instrumentation/ExecutorServiceMetrics.scala | 108 +-------------------- .../instrumentation/MessageQueueMetrics.scala | 29 ++---- 2 files changed, 14 insertions(+), 123 deletions(-) (limited to 'kamon-core/src/main/scala/kamon/instrumentation') diff --git a/kamon-core/src/main/scala/kamon/instrumentation/ExecutorServiceMetrics.scala b/kamon-core/src/main/scala/kamon/instrumentation/ExecutorServiceMetrics.scala index 995b8e7f..a3da76f7 100644 --- a/kamon-core/src/main/scala/kamon/instrumentation/ExecutorServiceMetrics.scala +++ b/kamon-core/src/main/scala/kamon/instrumentation/ExecutorServiceMetrics.scala @@ -19,14 +19,13 @@ import org.aspectj.lang.annotation._ import java.util.concurrent._ import org.aspectj.lang.ProceedingJoinPoint import java.util -import kamon.metric.{DispatcherMetricCollector, Histogram, MetricDirectory, ExecutorServiceMetricCollector} -import akka.dispatch.{MonitorableThreadFactory, ExecutorServiceFactory} +import kamon.metric.{ DispatcherMetricCollector, Histogram, MetricDirectory, ExecutorServiceMetricCollector } +import akka.dispatch.{ MonitorableThreadFactory, ExecutorServiceFactory } import com.typesafe.config.Config import kamon.Kamon import scala.concurrent.forkjoin.ForkJoinPool import akka.dispatch.ForkJoinExecutorConfigurator.AkkaForkJoinPool - @Aspect class ActorSystemInstrumentation { @@ -64,12 +63,9 @@ class ForkJoinPoolInstrumentation { } def splitName(threadFactoryName: String, knownActorSystems: List[String]): (String, String) = { - knownActorSystems.find(threadFactoryName.startsWith(_)).map(asName => (asName, threadFactoryName.substring(asName.length+1))).getOrElse(("Unkown", "Unkown")) + knownActorSystems.find(threadFactoryName.startsWith(_)).map(asName ⇒ (asName, threadFactoryName.substring(asName.length + 1))).getOrElse(("Unkown", "Unkown")) } - - - @Pointcut("execution(* scala.concurrent.forkjoin.ForkJoinPool.scan(..)) && this(fjp)") def forkJoinScan(fjp: AkkaForkJoinPool): Unit = {} @@ -79,39 +75,8 @@ class ForkJoinPoolInstrumentation { poolSizeHistogram.update(fjp.getPoolSize) } - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** * ExecutorService monitoring base: */ @@ -125,19 +90,6 @@ trait WatchedExecutorService { def collector: ExecutorServiceCollector } - - - - - - - - - - - - - trait ExecutorServiceMonitoring { def dispatcherMetrics: DispatcherMetricCollector } @@ -146,21 +98,6 @@ class ExecutorServiceMonitoringImpl extends ExecutorServiceMonitoring { @volatile var dispatcherMetrics: DispatcherMetricCollector = _ } - - - - - - - - - - - - - - - case class NamedExecutorServiceFactoryDelegate(actorSystemName: String, dispatcherName: String, delegate: ExecutorServiceFactory) extends ExecutorServiceFactory { def createExecutorService: ExecutorService = delegate.createExecutorService } @@ -178,8 +115,8 @@ class ExecutorServiceFactoryProviderInstrumentation { val delegate = pjp.proceed().asInstanceOf[ExecutorServiceFactory] // Safe Cast val actorSystemName = threadFactory match { - case m: MonitorableThreadFactory => m.name - case _ => "Unknown" // Find an alternative way to find the actor system name in case we start seeing "Unknown" as the AS name. + case m: MonitorableThreadFactory ⇒ m.name + 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, dispatcherName, delegate) @@ -187,7 +124,6 @@ class ExecutorServiceFactoryProviderInstrumentation { } - @Aspect class NamedExecutorServiceFactoryDelegateInstrumentation { @@ -224,37 +160,3 @@ case class NamedExecutorServiceDelegate(fullName: String, delegate: ExecutorServ def execute(command: Runnable) = delegate.execute(command) } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/kamon-core/src/main/scala/kamon/instrumentation/MessageQueueMetrics.scala b/kamon-core/src/main/scala/kamon/instrumentation/MessageQueueMetrics.scala index 65539beb..da797fa1 100644 --- a/kamon-core/src/main/scala/kamon/instrumentation/MessageQueueMetrics.scala +++ b/kamon-core/src/main/scala/kamon/instrumentation/MessageQueueMetrics.scala @@ -15,20 +15,18 @@ * ========================================================== */ package kamon.instrumentation -import com.codahale.metrics.{ExponentiallyDecayingReservoir, Histogram} -import akka.dispatch.{UnboundedMessageQueueSemantics, Envelope, MessageQueue} -import org.aspectj.lang.annotation.{Around, Pointcut, DeclareMixin, Aspect} -import akka.actor.{ActorSystem, ActorRef} -import kamon.metric.{Metrics, MetricDirectory} +import com.codahale.metrics.{ ExponentiallyDecayingReservoir, Histogram } +import akka.dispatch.{ UnboundedMessageQueueSemantics, Envelope, MessageQueue } +import org.aspectj.lang.annotation.{ Around, Pointcut, DeclareMixin, Aspect } +import akka.actor.{ ActorSystem, ActorRef } +import kamon.metric.{ Metrics, MetricDirectory } import org.aspectj.lang.ProceedingJoinPoint - /** * For Mailboxes we would like to track the queue size and message latency. Currently the latency * will be gathered from the ActorCellMetrics. */ - @Aspect class MessageQueueInstrumentation { @@ -40,7 +38,7 @@ class MessageQueueInstrumentation { val delegate = pjp.proceed.asInstanceOf[MessageQueue] // We are not interested in monitoring mailboxes if we don't know where they belong to. - val monitoredMailbox = for(own <- owner; sys <- system) yield { + val monitoredMailbox = for (own ← owner; sys ← system) yield { val systemName = sys.name val ownerName = MetricDirectory.nameForActor(own) val mailBoxName = MetricDirectory.nameForMailbox(systemName, ownerName) @@ -52,14 +50,13 @@ class MessageQueueInstrumentation { } monitoredMailbox match { - case None => delegate - case Some(mmb) => mmb + case None ⇒ delegate + case Some(mmb) ⇒ mmb } } } - -class MonitoredMessageQueue(val delegate: MessageQueue, val queueSizeHistogram: Histogram) extends MessageQueue with UnboundedMessageQueueSemantics{ +class MonitoredMessageQueue(val delegate: MessageQueue, val queueSizeHistogram: Histogram) extends MessageQueue with UnboundedMessageQueueSemantics { def enqueue(receiver: ActorRef, handle: Envelope) = { delegate.enqueue(receiver, handle) @@ -78,11 +75,3 @@ class MonitoredMessageQueue(val delegate: MessageQueue, val queueSizeHistogram: def cleanUp(owner: ActorRef, deadLetters: MessageQueue) = delegate.cleanUp(owner, deadLetters) } - - - - - - - - -- cgit v1.2.3