All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.undefinedlabs.scope.rules.ScalaActorSelectionScopeAgentRule Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 0.15.1-beta.2
Show newest version
package com.undefinedlabs.scope.rules;

import akka.actor.ActorRef;
import akka.actor.ScalaActorRef;
import com.undefinedlabs.scope.rules.logic.ActorRefAdviceLogic;
import com.undefinedlabs.scope.rules.transformer.ScopeAgentAdvicedTransformer;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.asm.Advice;

import java.util.Collections;

import static net.bytebuddy.matcher.ElementMatchers.*;
import static net.bytebuddy.matcher.ElementMatchers.named;

public class ScalaActorSelectionScopeAgentRule extends AbstractScopeAgentRule {

    @Override
    protected Iterable transformers() {
        final Class instrumentedClass = lookUp("akka.actor.ScalaActorSelection");

        return  (instrumentedClass != null) ?
                Collections.singleton(newAgentBuilder()
                .type(isSubTypeOf(instrumentedClass), isSystemClassLoader()).transform(new ScopeAgentAdvicedTransformer(ScalaActorRefScopeAgentRule.BangAdvice.class, named("$bang"))))
                : emptyCollection();
    }

    public static class BangAdvice {

        @Advice.OnMethodEnter
        public static void enter(@Advice.This ScalaActorRef thiz, @Advice.Argument(value = 0, readOnly = false) Object msg, @Advice.Argument(1) Object senderActorRefObj) {
            final Object tracingMsg = ActorRefAdviceLogic.tellAdvice((ActorRef) thiz, msg, senderActorRefObj);
            if(tracingMsg == null) {
                return;
            }

            msg = tracingMsg;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy