com.undefinedlabs.scope.rules.ScalaActorRefScopeAgentRule 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 akka.actor.ActorRef;
import akka.actor.ScalaActorRef;
import akka.pattern.PromiseActorRef;
import com.undefinedlabs.scope.ScopeGlobalTracer;
import com.undefinedlabs.scope.propagation.wrappers.TracingWrapper;
import com.undefinedlabs.scope.propagation.wrappers.TracingWrapperUtils;
import com.undefinedlabs.scope.rules.logic.ActorRefAdviceLogic;
import com.undefinedlabs.scope.rules.transformer.ScopeAgentAdvicedTransformer;
import com.undefinedlabs.scope.utils.tag.TagKeys;
import com.undefinedlabs.scope.utils.tag.TagValues;
import io.opentracing.Span;
import io.opentracing.Tracer;
import io.opentracing.propagation.Format;
import io.opentracing.propagation.TextMapAdapter;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.asm.Advice;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import static net.bytebuddy.matcher.ElementMatchers.*;
import static net.bytebuddy.matcher.ElementMatchers.named;
public class ScalaActorRefScopeAgentRule extends AbstractScopeAgentRule {
@Override
protected Iterable extends AgentBuilder> transformers() {
final Class instrumentedClass = lookUp("akka.actor.ScalaActorRef");
return (instrumentedClass != null) ?
Collections.singleton(newAgentBuilder()
.type(isSubTypeOf(instrumentedClass), isSystemClassLoader()).transform(new ScopeAgentAdvicedTransformer(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