static Activity StartIfEnabled(DiagnosticSource source, string name, object args, ConsumeContext context)
        {
            if (!source.IsEnabled(name) || context.TryGetPayload <Activity>(out _))
            {
                return(null);
            }

            var activity = new Activity(name)
                           .AddTag("message-id", context.MessageId.ToString())
                           .AddTag("initiator-id", context.InitiatorId.ToString())
                           .AddTag("source-address", context.SourceAddress.ToString())
                           .AddTag("environment-host-machine", context.Host.MachineName)
                           .AddTag("environment-host-framework-version", context.Host.FrameworkVersion)
                           .AddTag("environment-host-process-id", context.Host.ProcessId.ToString())
                           .AddTag("environment-host-mt-version", context.Host.MassTransitVersion)
                           .AddTag("message-types", string.Join(",", context.SupportedMessageTypes))
                           .AddBaggage("correlation-id", context.CorrelationId.ToString())
                           .AddBaggage("correlation-conversation-id", context.ConversationId.ToString());

            Extract(context, activity);

            source.StartActivity(activity, args ?? new { });

            return(context.AddOrUpdatePayload(() => activity, a => activity));
        }
Esempio n. 2
0
        public async Task Send(ConsumeContext <TMessage> context, IPipe <ConsumeContext <TMessage> > next)
        {
            if (context.RequestId.HasValue)
            {
                var clientId = context.Headers.Get(MessageHeaders.ClientId, default(Guid?));
                if (clientId.HasValue)
                {
                    var acceptedContext = await _endpoint.Accept(clientId.Value, context.RequestId.Value).ConfigureAwait(false);

                    context.AddOrUpdatePayload(() => acceptedContext, existing => acceptedContext);

                    await next.Send(context).ConfigureAwait(false);
                }
                else
                {
                    var exception = new RequestException($"ClientId not specified (requestId: {context.RequestId})");

                    await context.NotifyFaulted(TimeSpan.Zero, TypeMetadataCache <ConductorMessageFilter <TMessage> > .ShortName, exception).ConfigureAwait(false);
                }
            }
            else
            {
                var exception = new RequestException("RequestId is required");

                await context.NotifyFaulted(TimeSpan.Zero, TypeMetadataCache <ConductorMessageFilter <TMessage> > .ShortName, exception).ConfigureAwait(false);
            }
        }
        Activity StartIfEnabled(DiagnosticSource source, string name, object args, ConsumeContext context)
        {
            if (!source.IsEnabled(name) || context.TryGetPayload <Activity>(out _))
            {
                return(null);
            }

            var activity = new Activity(name)
                           .AddTag(DiagnosticHeaders.MessageId, context.MessageId.ToString())
                           .AddTag(DiagnosticHeaders.InitiatorId, context.InitiatorId.ToString())
                           .AddTag(DiagnosticHeaders.SourceAddress, context.SourceAddress.ToString())
                           .AddTag(DiagnosticHeaders.DestinationAddress, context.DestinationAddress.ToString())
                           .AddTag(DiagnosticHeaders.InputAddress, context.ReceiveContext.InputAddress.ToString())
                           .AddTag(DiagnosticHeaders.SourceHostMachine, context.Host.MachineName)
                           .AddTag(DiagnosticHeaders.SourceHostFrameworkVersion, context.Host.FrameworkVersion)
                           .AddTag(DiagnosticHeaders.SourceHostProcessId, context.Host.ProcessId.ToString())
                           .AddTag(DiagnosticHeaders.SourceHostMassTransitVersion, context.Host.MassTransitVersion)
                           .AddTag(DiagnosticHeaders.MessageTypes, string.Join(",", context.SupportedMessageTypes))
                           .AddBaggage(DiagnosticHeaders.CorrelationId, context.CorrelationId.ToString())
                           .AddBaggage(DiagnosticHeaders.CorrelationConversationId, context.ConversationId.ToString());

            Extract(context, activity);

            source.StartActivity(activity, args ?? new { });

            return(context.AddOrUpdatePayload(() => activity, a => activity));
        }