diff options
author | Ivan Topolnak <ivantopo@gmail.com> | 2013-11-04 18:11:16 -0300 |
---|---|---|
committer | Ivan Topolnak <ivantopo@gmail.com> | 2013-11-04 18:11:16 -0300 |
commit | 84711adba09c64b75369f8b801819a90198238c6 (patch) | |
tree | 1e6193bf3248e82a85c1091110ba3b81d3f34036 /kamon-core | |
parent | 227c2dfe6cb8b7e175ad72285dfdfbd15672be24 (diff) | |
download | Kamon-84711adba09c64b75369f8b801819a90198238c6.tar.gz Kamon-84711adba09c64b75369f8b801819a90198238c6.tar.bz2 Kamon-84711adba09c64b75369f8b801819a90198238c6.zip |
wip
Diffstat (limited to 'kamon-core')
4 files changed, 1 insertions, 164 deletions
diff --git a/kamon-core/src/main/resources/META-INF/aop.xml b/kamon-core/src/main/resources/META-INF/aop.xml index f13effb9..c63e17e5 100644 --- a/kamon-core/src/main/resources/META-INF/aop.xml +++ b/kamon-core/src/main/resources/META-INF/aop.xml @@ -9,7 +9,7 @@ <aspect name="kamon.instrumentation.EnvelopeTracingContext"/> <aspect name="kamon.instrumentation.ActorCellInvokeInstrumentation"/> - <aspect name="kamon.instrumentation.RunnableInstrumentation" /> + <aspect name="kamon.trace.instrumentation.RunnableTracing" /> <aspect name="kamon.instrumentation.SprayRequestContextTracing"/> <aspect name="kamon.instrumentation.SprayOpenRequestContextTracing"/> <aspect name = "kamon.instrumentation.SprayServerInstrumentation"/> diff --git a/kamon-core/src/main/scala/kamon/Kamon.scala b/kamon-core/src/main/scala/kamon/Kamon.scala index 75ef1efe..8c934f60 100644 --- a/kamon-core/src/main/scala/kamon/Kamon.scala +++ b/kamon-core/src/main/scala/kamon/Kamon.scala @@ -20,53 +20,6 @@ object Kamon { def apply[T <: Extension](key: ExtensionId[T])(implicit system: ActorSystem): ActorRef = key(system).manager - - - - - - implicit lazy val actorSystem = ActorSystem("kamon") - - object Metric { - - val actorSystems = TrieMap.empty[String, ActorSystemMetrics] - - def actorSystemNames: List[String] = actorSystems.keys.toList - def registerActorSystem(name: String) = actorSystems.getOrElseUpdate(name, ActorSystemMetrics(name)) - - def actorSystem(name: String): Option[ActorSystemMetrics] = actorSystems.get(name) - } - - //val metricManager = actorSystem.actorOf(Props[MetricManager], "metric-manager") - //val newrelicReporter = actorSystem.actorOf(Props[NewrelicReporterActor], "newrelic-reporter") - -} - - -class MetricManager extends Actor { - implicit val ec = context.system.dispatcher - - def receive = { - case RegisterForAllDispatchers(frequency) => { - val subscriber = sender - context.system.scheduler.schedule(frequency, frequency) { - Kamon.Metric.actorSystems.foreach { - case (asName, actorSystemMetrics) => actorSystemMetrics.dispatchers.foreach { - case (dispatcherName, dispatcherMetrics) => { - val activeThreads = dispatcherMetrics.activeThreadCount.snapshot - val poolSize = dispatcherMetrics.poolSize.snapshot - val queueSize = dispatcherMetrics.queueSize.snapshot - - subscriber ! DispatcherMetrics(asName, dispatcherName, activeThreads, poolSize, queueSize) - - } - } - } - } - } - } } -case class RegisterForAllDispatchers(frequency: FiniteDuration) -case class DispatcherMetrics(actorSystem: String, dispatcher: String, activeThreads: HistogramSnapshot, poolSize: HistogramSnapshot, queueSize: HistogramSnapshot) diff --git a/kamon-core/src/main/scala/kamon/instrumentation/RunnableInstrumentation.scala b/kamon-core/src/main/scala/kamon/instrumentation/RunnableInstrumentation.scala deleted file mode 100644 index 2be6e5d1..00000000 --- a/kamon-core/src/main/scala/kamon/instrumentation/RunnableInstrumentation.scala +++ /dev/null @@ -1,59 +0,0 @@ -package kamon.instrumentation - -import org.aspectj.lang.annotation._ -import kamon.{Tracer} -import org.aspectj.lang.ProceedingJoinPoint -import scala.Some -import kamon.trace.TraceContext - -/** - * Marker interface, just to make sure we don't instrument all the Runnables in the classpath. - */ -trait TraceContextAwareRunnable { - def traceContext: Option[TraceContext] -} - - -@Aspect -class RunnableInstrumentation { - - /** - * These are the Runnables that need to be instrumented and make the TraceContext available - * while their run method is executed. - */ - @DeclareMixin("scala.concurrent.impl.CallbackRunnable || scala.concurrent.impl.Future.PromiseCompletingRunnable") - def onCompleteCallbacksRunnable: TraceContextAwareRunnable = new TraceContextAwareRunnable { - val traceContext: Option[TraceContext] = Tracer.traceContext.value - } - - - /** - * Pointcuts - */ - - @Pointcut("execution(kamon.instrumentation.TraceContextAwareRunnable+.new(..)) && this(runnable)") - def instrumentedRunnableCreation(runnable: TraceContextAwareRunnable): Unit = {} - - @Pointcut("execution(* kamon.instrumentation.TraceContextAwareRunnable+.run()) && this(runnable)") - def runnableExecution(runnable: TraceContextAwareRunnable) = {} - - - - @After("instrumentedRunnableCreation(runnable)") - def beforeCreation(runnable: TraceContextAwareRunnable): Unit = { - // Force traceContext initialization. - runnable.traceContext - } - - - @Around("runnableExecution(runnable)") - def around(pjp: ProceedingJoinPoint, runnable: TraceContextAwareRunnable): Any = { - import pjp._ - - Tracer.traceContext.withValue(runnable.traceContext) { - proceed() - } - } - -} - diff --git a/kamon-core/src/main/scala/kamon/trace/UowTracing.scala b/kamon-core/src/main/scala/kamon/trace/UowTracing.scala deleted file mode 100644 index b09478cc..00000000 --- a/kamon-core/src/main/scala/kamon/trace/UowTracing.scala +++ /dev/null @@ -1,57 +0,0 @@ -package kamon.trace - -import akka.actor._ -import scala.concurrent.duration.Duration -import kamon.trace.UowTracing._ - -sealed trait UowSegment { - def timestamp: Long -} - -trait AutoTimestamp extends UowSegment { - val timestamp = System.nanoTime -} - -object UowTracing { - case class Start() extends AutoTimestamp - case class Finish() extends AutoTimestamp - case class Rename(name: String) extends AutoTimestamp - case class WebExternalStart(id: Long, host: String) extends AutoTimestamp - case class WebExternalFinish(id: Long) extends AutoTimestamp - case class WebExternal(start: Long, finish: Long, host: String) extends AutoTimestamp -} - -case class UowTrace(name: String, segments: Seq[UowSegment]) - - -class UowTraceAggregator(reporting: ActorRef, aggregationTimeout: Duration) extends Actor with ActorLogging { - context.setReceiveTimeout(aggregationTimeout) - - var name: Option[String] = None - var segments: Seq[UowSegment] = Nil - - var pendingExternal = List[WebExternalStart]() - - def receive = { - case finish: Finish => segments = segments :+ finish; finishTracing() - case wes: WebExternalStart => pendingExternal = pendingExternal :+ wes - case finish @ WebExternalFinish(id) => pendingExternal.find(_.id == id).map(start => { - segments = segments :+ WebExternal(start.timestamp, finish.timestamp, start.host) - }) - case Rename(newName) => name = Some(newName) - case segment: UowSegment => segments = segments :+ segment - case ReceiveTimeout => - log.warning("Transaction {} did not complete properly, the recorded segments are: {}", name, segments) - context.stop(self) - } - - def finishTracing(): Unit = { - reporting ! UowTrace(name.getOrElse("UNKNOWN"), segments) - println("Recorded Segments: " + segments) - context.stop(self) - } -} - -object UowTraceAggregator { - def props(reporting: ActorRef, aggregationTimeout: Duration) = Props(classOf[UowTraceAggregator], reporting, aggregationTimeout) -}
\ No newline at end of file |