private static void ProcessCommand(IProfiledCommand profiledCommand, IExecutionSegment executionSegment) { var name = GetCommand(profiledCommand); if (profiledCommand.RetransmissionOf != null) { var retransmissionName = GetCommand(profiledCommand.RetransmissionOf); name += $" (Retransmission of {retransmissionName}: {profiledCommand.RetransmissionReason})"; } executionSegment.CaptureSpan(name, ApiConstants.TypeDb, span => { span.Context.Db = new Database { Instance = profiledCommand.Db.ToString(CultureInfo.InvariantCulture), Statement = GetCommandAndKey(profiledCommand) ?? name, Type = ApiConstants.SubTypeRedis }; string address = null; int?port = null; switch (profiledCommand.EndPoint) { case IPEndPoint ipEndPoint: address = ipEndPoint.Address.ToString(); port = ipEndPoint.Port; break; case DnsEndPoint dnsEndPoint: address = dnsEndPoint.Host; port = dnsEndPoint.Port; break; } if (address != null) { span.Context.Destination = new Destination { Address = address, Port = port } } ; // update the timestamp to reflect the point at which the command was created if (span is Span realSpan) { realSpan.Timestamp = TimeUtils.ToTimestamp(profiledCommand.CommandCreated); } span.Duration = profiledCommand.ElapsedTime.TotalMilliseconds; // profiled commands are always successful span.Outcome = Outcome.Success; // TODO: clear the raw stacktrace as it won't be representative of the call stack at // the point at which the call to redis happens, and therefore misleading to include }, ApiConstants.SubTypeRedis, "query", true); }