Ejemplo n.º 1
0
 public static ClientSpan Create(IClientSpanLocate locate)
 {
     return(new ClientSpan()
     {
         TraceId = locate.TraceId, ParentSpanId = locate.ParentSpanId, SpanId = locate.SpanId
     });
 }
        private static bool IsBadClientSpan(IClientSpanLocate locate, ClientSpanLocateMode mode)
        {
            if (locate == null)
            {
                return(true);
            }

            if (string.IsNullOrWhiteSpace(locate.TracerId))
            {
                return(true);
            }

            if (string.IsNullOrWhiteSpace(locate.TraceId))
            {
                return(true);
            }

            if (mode == ClientSpanLocateMode.ForParent)
            {
                if (string.IsNullOrWhiteSpace(locate.ParentSpanId))
                {
                    return(true);
                }
            }
            else
            {
                if (string.IsNullOrWhiteSpace(locate.SpanId))
                {
                    return(true);
                }
            }

            return(false);
        }
 public static bool ValidateNewClientSpan(IClientSpanLocate locate)
 {
     if (locate == null)
     {
         return(false);
     }
     return(!IsBadClientSpan(locate, ClientSpanLocateMode.ForCurrent));
 }
Ejemplo n.º 4
0
 public static ClientSpan Create(IClientSpanLocate locate, string opName, IDictionary <string, string> bags = null)
 {
     if (locate == null)
     {
         throw new ArgumentNullException(nameof(locate));
     }
     return(Create(locate.TracerId, locate.TraceId, locate.SpanId, locate.ParentSpanId, opName, bags));
 }
 public static T With <T>(T locate, IClientSpanLocate setter) where T : IClientSpanLocate
 {
     if (locate == null || setter == null)
     {
         return(locate);
     }
     return(With(locate, setter.TracerId, setter.TraceId, setter.ParentSpanId, setter.SpanId));
 }
 public static string ToDisplayKey(IClientSpanLocate locate)
 {
     if (locate == null)
     {
         return(null);
     }
     return(string.IsNullOrWhiteSpace(locate.ParentSpanId) ?
            string.Format("{0}_{1}_{2}", locate.TracerId, locate.TraceId, locate.SpanId) :
            string.Format("{0}_{1}_{2}_{3}", locate.TracerId, locate.TraceId, locate.ParentSpanId, locate.SpanId));
 }
        public static string ToLocateParentKey(IClientSpanLocate locate)
        {
            if (locate == null)
            {
                return(null);
            }
            var locateKey = ToLocateKey(locate.TraceId, locate.ParentSpanId);

            return(locateKey);
        }
Ejemplo n.º 8
0
 public static string ToLocateKey(this IClientSpanLocate locate)
 {
     if (locate == null)
     {
         return(null);
     }
     return(string.IsNullOrWhiteSpace(locate.ParentSpanId) ?
            string.Format("{0}-{1}", locate.TraceId, locate.SpanId) :
            string.Format("{0}-{1}-{2}", locate.TraceId, locate.ParentSpanId, locate.SpanId));
 }
Ejemplo n.º 9
0
 public async Task <ClientSpan> GetSpan(IClientSpanLocate args)
 {
     using (await _asyncLock.LockAsync())
     {
         ClientSpan clientSpan = null;
         if (ClientSpans.ContainsKey(args.SpanId))
         {
             clientSpan = ClientSpans[args.SpanId];
         }
         return(await Task.FromResult(clientSpan));
     }
 }
Ejemplo n.º 10
0
        public static T AutoSet <T>(this T locate, IClientSpanLocate setter) where T : IClientSpanLocate
        {
            if (locate == null || setter == null)
            {
                return(locate);
            }

            locate.SpanId       = setter.SpanId;
            locate.TraceId      = setter.TraceId;
            locate.ParentSpanId = setter.ParentSpanId;
            return(locate);
        }
Ejemplo n.º 11
0
        public static ClientSpan TryCreate(ClientSpanLocateMode mode, IClientSpanLocate locate, string opName, IDictionary <string, string> bags = null)
        {
            var shouldReturnNull = locate.IsBadLocateArgs(mode);

            if (shouldReturnNull)
            {
                return(null);
            }

            var clientSpan = new ClientSpan();

            clientSpan.With(locate);
            clientSpan.OpName = opName;
            if (bags != null)
            {
                clientSpan.Bags = bags;
            }
            return(clientSpan);
        }
 public static string ToDisplayKey(this IClientSpanLocate locate)
 {
     return(ClientSpanLocateKeyHelper.ToDisplayKey(locate));
 }
 public static string ToLocateParentKey(this IClientSpanLocate locate)
 {
     return(ClientSpanLocateKeyHelper.ToLocateParentKey(locate));
 }
 public static bool ValidateNewClientSpan(this IClientSpanLocate locate)
 {
     return(ClientSpanLocateKeyHelper.ValidateNewClientSpan(locate));
 }
 public static bool IsBadLocateArgs(this IClientSpanLocate locate, ClientSpanLocateMode mode)
 {
     return(ClientSpanLocateKeyHelper.IsBadLocateArgs(locate, mode));
 }
 public static T With <T>(this T locate, IClientSpanLocate setter) where T : IClientSpanLocate
 {
     return(ClientSpanLocateKeyHelper.With(locate, setter));
 }
 public static bool IsBadLocateArgs(IClientSpanLocate locate, ClientSpanLocateMode mode)
 {
     return(IsBadClientSpan(locate, mode));
 }