com.undefinedlabs.scope.rules.ScalaActorSelectionScopeAgentRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scope-rule-akka Show documentation
Show all versions of scope-rule-akka Show documentation
Scope is a APM for tests to give engineering teams unprecedented visibility into their CI process to quickly
identify, troubleshoot and fix failed builds.
This artifact contains the classes to instrument the Akka.
package com.undefinedlabs.scope.rules;
import static com.undefinedlabs.scope.agent.ScopeClassLoaderMatcher.hasClassesNamed;
import static net.bytebuddy.matcher.ElementMatchers.hasSuperType;
import static net.bytebuddy.matcher.ElementMatchers.named;
import akka.actor.ActorRef;
import akka.actor.ScalaActorRef;
import com.undefinedlabs.scope.rules.logic.ActorRefAdviceLogic;
import java.util.HashMap;
import java.util.Map;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
public class ScalaActorSelectionScopeAgentRule extends AbstractScopeAgentRule {
@Override
protected ElementMatcher super TypeDescription> typeMatcher() {
return hasSuperType(named("akka.actor.ScalaActorSelection"));
}
@Override
protected ElementMatcher classLoaderMatcher() {
return hasClassesNamed("akka.actor.ScalaActorRef");
}
@Override
protected Map extends ElementMatcher super MethodDescription>, String> transformers() {
final Map, String> transformers = new HashMap<>();
transformers.put(
named("$bang"), ScalaActorSelectionScopeAgentRule.class.getName() + "$BangAdvice");
return transformers;
}
public static class BangAdvice {
@Advice.OnMethodEnter
public static void enter(
@Advice.This final ScalaActorRef thiz,
@Advice.Argument(value = 0, readOnly = false) Object msg,
@Advice.Argument(1) final Object senderActorRefObj) {
final Object tracingMsg =
ActorRefAdviceLogic.tellAdvice((ActorRef) thiz, msg, senderActorRefObj);
if (tracingMsg == null) {
return;
}
msg = tracingMsg;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy