blob: ae21aa130fb7a6336bf9bc9fcec39cfe9a420e8c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package akka
import actor.ActorCell
import org.aspectj.lang.annotation.{After, Around, Pointcut, Aspect}
import org.aspectj.lang.ProceedingJoinPoint
import kamon.metric.Metrics.{ metricsRegistry => meterRegistry }
import com.codahale.metrics.Meter
import kamon.metric.MetricsUtils._
@Aspect("perthis(actorCellCreation(*))")
class ActorAspect {
/**
* Aspect members
*/
private val actorMeter:Meter = new Meter
/**
* Pointcuts
*/
@Pointcut("execution(akka.actor.ActorCell+.new(..)) && this(actor)")
def actorCellCreation(actor:ActorCell):Unit = {}
@Pointcut("execution(* akka.actor.ActorCell+.receiveMessage(..))")
def actorReceive():Unit = {}
/**
* Advices
*/
@After("actorCellCreation(actor)")
def afterCellCreation(actor:ActorCell):Unit ={
val actorName:String = actor.self.path.toString
meterRegistry.register(s"meter-for-${actorName}", actorMeter)
}
@Around("actorReceive()")
def around(pjp: ProceedingJoinPoint) = {
import pjp._
markMeter(actorMeter) {
proceed
}
}
}
|