com.undefinedlabs.scope.rules.logic.ActorRefAdviceLogic 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.logic;
import akka.actor.ActorRef;
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.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 java.util.HashMap;
import java.util.Map;
public class ActorRefAdviceLogic {
public static Object tellAdvice(
final ActorRef thiz, final Object msg, final Object senderActorRefObj) {
if (thiz instanceof PromiseActorRef) {
return null;
}
if (msg instanceof TracingWrapper) {
return null;
}
final Tracer tracer = ScopeGlobalTracer.get();
final Span previousActiveSpan = tracer.activeSpan();
if (previousActiveSpan == null) {
return null;
}
final ActorRef senderActorRef =
(senderActorRefObj != null) ? (ActorRef) senderActorRefObj : ActorRef.noSender();
final Span span =
tracer
.buildSpan("Akka TELL")
.withTag(TagKeys.SPAN_KIND, TagValues.Message.SPAN_KIND_PRODUCER)
.withTag(TagKeys.COMPONENT, TagValues.Component.AKKA)
.withTag(TagKeys.Network.Akka.Actor.PATH, thiz.path().toStringWithoutAddress())
.withTag(TagKeys.Network.Akka.Actor.ADDRESS, thiz.path().address().toString())
.withTag(
TagKeys.Network.Akka.Actor.RECV_SENDER,
(senderActorRef != null) ? senderActorRef.path().toString() : null)
.withTag(
TagKeys.Network.Akka.Actor.MESSAGE_TYPE,
(msg != null) ? msg.getClass().getName() : null)
.withTag(TagKeys.LANGUAGE, TagValues.Language.SCALA)
.start();
final Map headers = new HashMap<>();
tracer.inject(span.context(), Format.Builtin.TEXT_MAP, new TextMapAdapter(headers));
span.finish();
return TracingWrapperUtils.wrapWithTracingHeaders(headers, msg);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy