public override void OnStartActivity(Activity activity, object payload)
        {
            if (!(payload is IIncomingPhysicalMessageContext context))
            {
                return;
            }

            var settings = context.Builder.Build <ReadOnlySettings>();

            activity.SetKind(ActivityKind.Consumer);
            activity.DisplayName = settings.LogicalAddress().ToString();

            _activitySource.Start(activity);

            if (activity.IsAllDataRequested)
            {
                activity.AddTag("messaging.message_id", context.Message.MessageId);
                activity.AddTag("messaging.operation", "process");
                activity.AddTag("messaging.message_payload_size_bytes", context.Message.Body.Length.ToString());

                if (_options.CaptureMessageBody)
                {
                    activity.AddTag("messaging.message_payload", Encoding.UTF8.GetString(context.Message.Body));
                }

                activity.ApplyContext(settings, context.MessageHeaders);
            }
        }
Ejemplo n.º 2
0
 public override void OnStartActivity(Activity activity, object payload)
 {
     if (!options.TracedOperations.Contains(activity.OperationName))
     {
         return;
     }
     activitySource.Start(activity, ActivityKind.Server);
 }
Ejemplo n.º 3
0
        public override void OnStartActivity(Activity activity, object payload)
        {
            // add more tags
            activity.AddTag("request", activity.OperationName);
            activity.AddTag("request.data", JsonSerializer.Serialize(payload));

            activity.SetKind(ActivityKind.Server);

            _activitySource.Start(activity);
        }
Ejemplo n.º 4
0
        public override void OnStartActivity(Activity activity, object payload)
        {
            if (!(payload is CommandStartedEvent message))
            {
                return;
            }

            activity.DisplayName = $"mongodb.{message.CommandName}";

            _activitySource.Start(activity, ActivityKind.Client);

            if (activity.IsAllDataRequested)
            {
                activity.AddTag("db.type", "mongo");
                activity.AddTag("db.instance", message.DatabaseNamespace.DatabaseName);
                var endPoint = message.ConnectionId?.ServerId?.EndPoint;
                switch (endPoint)
                {
                case IPEndPoint ipEndPoint:
                    activity.AddTag("db.user", $"mongodb://{ipEndPoint.Address}:{ipEndPoint.Port}");
                    activity.AddTag("net.peer.ip", ipEndPoint.Address.ToString());
                    activity.AddTag("net.peer.port", ipEndPoint.Port.ToString());
                    break;

                case DnsEndPoint dnsEndPoint:
                    activity.AddTag("db.user", $"mongodb://{dnsEndPoint.Host}:{dnsEndPoint.Port}");
                    activity.AddTag("net.peer.name", dnsEndPoint.Host);
                    activity.AddTag("net.peer.port", dnsEndPoint.Port.ToString());
                    break;
                }

                if (_options.CaptureCommandText)
                {
                    activity.AddTag("db.statement", message.Command.ToString());
                }
            }
        }