-
-
Save markon/c3cecdf12f083484d0a8fa5d6f987d54 to your computer and use it in GitHub Desktop.
AspectJ instrumentation to collect custom metrics for user actors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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