コード例 #1
0
        internal static void SetTagsFromBasicProperties(RabbitMQTags tags, IBasicProperties basicProperties)
        {
            tags.ConversationId = basicProperties.CorrelationId;
            tags.MessageId      = basicProperties.MessageId;

            if (basicProperties.IsDeliveryModePresent())
            {
                tags.DeliveryMode = DeliveryModeStrings[0x3 & basicProperties.DeliveryMode];
            }
        }
コード例 #2
0
        internal static Scope CreateScope(Tracer tracer, out RabbitMQTags tags, string command, string spanKind, ISpanContext parentContext = null, DateTimeOffset?startTime = null, string queue = null, string exchange = null, string routingKey = null)
        {
            tags = null;

            if (!tracer.Settings.IsIntegrationEnabled(IntegrationId))
            {
                // integration disabled, don't create a scope, skip this trace
                return(null);
            }

            Scope scope = null;

            try
            {
                tags = new RabbitMQTags(spanKind);
                string serviceName = tracer.Settings.GetServiceName(tracer, ServiceName);
                scope = tracer.StartActiveInternal(OperationName, parent: parentContext, tags: tags, serviceName: serviceName, startTime: startTime);
                var span = scope.Span;

                span.Type         = SpanTypes.Queue;
                span.ResourceName = command;
                tags.Command      = command;

                tags.Queue      = queue;
                tags.Exchange   = exchange;
                tags.RoutingKey = routingKey;

                tags.InstrumentationName = IntegrationName;
                tags.SetAnalyticsSampleRate(IntegrationId, tracer.Settings, enabledWithGlobalSetting: false);
                tracer.TracerManager.Telemetry.IntegrationGeneratedSpan(IntegrationId);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Error creating or populating scope.");
            }

            // always returns the scope, even if it's null because we couldn't create it,
            // or we couldn't populate it completely (some tags is better than no tags)
            return(scope);
        }
コード例 #3
0
        internal static Scope CreateScope(Tracer tracer, out RabbitMQTags tags, string command, string spanKind, ISpanContext parentContext = null, DateTimeOffset?startTime = null, string queue = null, string exchange = null, string routingKey = null)
        {
            tags = null;

            if (!tracer.Settings.IsIntegrationEnabled(IntegrationId))
            {
                // integration disabled, don't create a scope, skip this trace
                return(null);
            }

            Scope scope = null;

            try
            {
                tags = new RabbitMQTags(spanKind);
                string operation     = CommandToOperation(command);
                string operationName = string.IsNullOrWhiteSpace(exchange)
                    ? $"(default) {operation}"
                    : $"{exchange} {operation}";

                string serviceName = tracer.Settings.GetServiceName(tracer, ServiceName);
                scope = tracer.StartActiveInternal(operationName, parent: parentContext, tags: tags, serviceName: serviceName, startTime: startTime);
                var span = scope.Span;

                span.Type         = SpanTypes.Queue;
                span.LogicScope   = "amqp.command";
                span.ResourceName = command;

                // Network tags
                // TODO: tags.PeerName = "";
                // TODO: tags.PeerIP = "";

                // Messaging Tags
                tags.System          = SystemName;
                tags.Destination     = exchange;
                tags.DestinationKind = SpanTypes.Queue;
                // TODO: tags.TempDestination = "TODO";
                // TODO: tags.Protocol = "TODO";
                // TODO: tags.ProtocolVersion = "TODO";
                // TODO: tags.Url = "TODO";

                if (ReferenceEquals(operation, OperationReceive) ||
                    ReferenceEquals(operation, OperationProcess))
                {
                    tags.Operation = operation;

                    // tags.ConsumerId = "TODO";
                }

                // RabbitMq Tags
                tags.InstrumentationName = IntegrationName;
                tags.Queue      = queue;
                tags.Exchange   = exchange;
                tags.Command    = command;
                tags.RoutingKey = routingKey;

                tags.SetAnalyticsSampleRate(IntegrationId, tracer.Settings, enabledWithGlobalSetting: false);
                tracer.TracerManager.Telemetry.IntegrationGeneratedSpan(IntegrationId);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Error creating or populating scope.");
            }

            // always returns the scope, even if it's null because we couldn't create it,
            // or we couldn't populate it completely (some tags is better than no tags)
            return(scope);
        }