Example #1
0
        internal static async Task Receive(MessageEnvelope envelope, SpanSetup receiveSpanSetup, ITracer tracer, Func <Task> receive)
        {
            var message = envelope.Message;

            var parentSpanCtx = envelope.Header != null
              ? tracer.Extract(BuiltinFormats.TextMap, new TextMapExtractAdapter(envelope.Header.ToDictionary()))
              : null;

            using (var scope = tracer.BuildStartedScope(parentSpanCtx, nameof(Receive), message, receiveSpanSetup))
            {
                try
                {
                    var span = scope.Span;

                    if (envelope.Sender != null)
                    {
                        ProtoTags.SenderPID.Set(span, envelope.Sender.ToShortString());
                    }

                    receiveSpanSetup?.Invoke(span, message);

                    await receive().ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    ex.SetupSpan(scope.Span);
                    throw;
                }
            }
        }
        internal static async Task <T> RequestAsync <T>(PID target, object message, SpanSetup sendSpanSetup, ITracer tracer, Func <Task <T> > requestAsync)
        {
            using var scope = tracer.BuildStartedScope(tracer.ActiveSpan?.Context, nameof(Request), message, sendSpanSetup);

            try
            {
                ProtoTags.TargetPID.Set(scope.Span, target.ToString());
                return(await requestAsync().ConfigureAwait(false));
            }
            catch (Exception ex)
            {
                ex.SetupSpan(scope.Span);
                throw;
            }
        }
        internal static void Request(PID target, object message, SpanSetup sendSpanSetup, ITracer tracer, Action request)
        {
            using var scope = tracer.BuildStartedScope(tracer.ActiveSpan?.Context, nameof(Request), message, sendSpanSetup);

            try
            {
                ProtoTags.TargetPID.Set(scope.Span, target.ToString());
                request();
            }
            catch (Exception ex)
            {
                ex.SetupSpan(scope.Span);
                throw;
            }
        }
Example #4
0
        public static void Send(PID target, object message, SpanSetup sendSpanSetup, ITracer tracer, Action send)
        {
            using var scope = tracer.BuildStartedScope(tracer.ActiveSpan?.Context, nameof(Send), message, sendSpanSetup);

            try
            {
                ProtoTags.TargetPID.Set(scope.Span, target.ToShortString());
                send();
            }
            catch (Exception ex)
            {
                ex.SetupSpan(scope.Span);
                throw;
            }
        }