Ejemplo n.º 1
0
        public IScope AroundReceive(IActorContext context, TracedMessage tracedMessage, Type actorType)
        {
            var actorPath = context.Self.Path.ToString().Substring(context.Self.Path.Address.ToString().Length);

            string operationName = $"{actorPath}:{tracedMessage.Message.GetType().Name}";

            string parent  = "no";
            var    builder = _tracer.BuildSpan(operationName);

            if (tracedMessage.Span != null)
            {
                parent  = tracedMessage.Span.Context.SpanId;
                builder = builder.AsChildOf(tracedMessage.Span);
            }
            else if (tracedMessage.Context.Count != 0)
            {
                ISpanContext spanContext = _tracer.Extract(BuiltinFormats.TextMap, new TextMapExtractAdapter(tracedMessage.Context));
                parent  = spanContext.SpanId;
                builder = builder.AsChildOf(spanContext);
            }

            IScope ret = builder.StartActive(true);

            ret.Span.SetTag("sender.path", GetSenderPath(context.Sender));
            ret.Span.SetTag("receiver.path", GetLocalActorPath(context.Self));
            ret.Span.SetTag("receiver.type", actorType.ToString());
            ret.Span.SetTag("message.type", tracedMessage.Message.GetType().ToString());

            LocalLog($"> {context.Self.Path}.Tell({tracedMessage.Message}) Thread={Thread.CurrentThread.ManagedThreadId}, parent={parent}");

            return(ret);
        }
Ejemplo n.º 2
0
 private bool AddSpan(IActorRef receiver, IActorRef sender, ref object message)
 {
     if (!(message is TracedMessage))
     {
         IScope scope = _tracer.ScopeManager.Active;
         message = new TracedMessage(message, scope?.Span);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
        private bool AddSpanContext(IActorRef receiver, IActorRef sender, ref object message)
        {
            IScope scope = _tracer.ScopeManager.Active;

            if (!(message is TracedMessage) && scope?.Span != null)
            {
                var tm = new TracedMessage(message, null);
                _tracer.Inject(scope.Span.Context, BuiltinFormats.TextMap, new TextMapInjectAdapter(tm.Context));
                message = tm;
                return(true);
            }
            return(false);
        }