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

com.undefinedlabs.scope.rules.ActorSelectionScopeAgentRule 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 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 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 ActorSelectionScopeAgentRule extends AbstractScopeAgentRule {

  @Override
  protected ElementMatcher typeMatcher() {
    return hasSuperType(named("akka.actor.ActorSelection"));
  }

  @Override
  protected ElementMatcher classLoaderMatcher() {
    return hasClassesNamed("akka.actor.ActorRef");
  }

  @Override
  protected Map, String> transformers() {
    final Map, String> transformers = new HashMap<>();
    transformers.put(named("tell"), ActorSelectionScopeAgentRule.class.getName() + "$TellAdvice");
    return transformers;
  }

  public static class TellAdvice {

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

      msg = tracingMsg;
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy