diff options
author | Ivan Topolnak <ivantopo@gmail.com> | 2013-08-07 19:06:33 -0300 |
---|---|---|
committer | Ivan Topolnak <ivantopo@gmail.com> | 2013-08-07 19:06:33 -0300 |
commit | 923b88e8adef2f66b43e551fa4a0a1bbae5af7ff (patch) | |
tree | d555199f0c63b690ec51805b496ee2d54eb014da /kamon-core/src/main/scala/kamon/instrumentation/SampleInstrumentation.scala | |
parent | 1e6665e30d96772eab92aca4d23e176adcd88dc5 (diff) | |
download | Kamon-923b88e8adef2f66b43e551fa4a0a1bbae5af7ff.tar.gz Kamon-923b88e8adef2f66b43e551fa4a0a1bbae5af7ff.tar.bz2 Kamon-923b88e8adef2f66b43e551fa4a0a1bbae5af7ff.zip |
upgrading to akka 2.2
Diffstat (limited to 'kamon-core/src/main/scala/kamon/instrumentation/SampleInstrumentation.scala')
-rw-r--r-- | kamon-core/src/main/scala/kamon/instrumentation/SampleInstrumentation.scala | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/kamon-core/src/main/scala/kamon/instrumentation/SampleInstrumentation.scala b/kamon-core/src/main/scala/kamon/instrumentation/SampleInstrumentation.scala new file mode 100644 index 00000000..74261403 --- /dev/null +++ b/kamon-core/src/main/scala/kamon/instrumentation/SampleInstrumentation.scala @@ -0,0 +1,49 @@ +package kamon.instrumentation + +import com.codahale.metrics.{ExponentiallyDecayingReservoir, Histogram} +import org.aspectj.lang.annotation.{After, Pointcut, DeclareMixin, Aspect} + +class ActorCage(val name: String, val size: Int) { + + def doIt: Unit = println("name") +} + +trait CageMonitoring { + def histogram: Histogram + def count(value: Int): Unit +} + +class CageMonitoringImp extends CageMonitoring{ + final val histogram = new Histogram(new ExponentiallyDecayingReservoir()) + + def count(value: Int) = histogram.update(value) + +} + + +@Aspect +class InceptionAspect { + + @DeclareMixin("kamon.instrumentation.ActorCage") + def mixin: CageMonitoring = new CageMonitoringImp + + + @Pointcut("execution(* kamon.instrumentation.ActorCage.doIt()) && target(actorCage)") + def theActorCageDidIt(actorCage: CageMonitoring) = {} + + @After("theActorCageDidIt(actorCage)") + def afterDoingIt(actorCage: CageMonitoring) = { + actorCage.count(1) + actorCage.histogram.getSnapshot.dump(System.out) + } + + + +} + + +object Runner extends App { + val cage = new ActorCage("ivan", 10) + + cage.doIt +} |