AspectJ instrumentation to collect custom metrics for user actors
package metrics.instrumentation | |
import com.typesafe.config.ConfigFactory | |
import org.aspectj.lang.annotation._ | |
import org.slf4j.LoggerFactory | |
import models.messages.CustomActorEvent | |
import metrics.CustomMetrics | |
@Aspect | |
class CustomActorInstrumentation { | |
private val config = ConfigFactory.load() | |
@Pointcut("execution(* org.mypackage.actors.CustomActor.aroundReceive(..)) && args(*, msg)") | |
def onCustomActorMessagePointcut(msg: Any): Unit = {} | |
@Before("onCustomActorMessagePointcut(msg)") | |
def onCustomActorMessageHandler(msg: Any): Unit = { | |
val customMetrics = CustomMetrics.forSystem("my-system") | |
msg match { | |
case e: CustomActorEvent => | |
customMetrics.customEvent.increment() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment