Example #1
0
        public bool TryAdd([NotNull] TraceContextInfo info)
        {
            var capacityLimit = configProvider.GetConfig().MaxBufferedSpans;

            lock (syncObject)
            {
                if (infos.Count >= capacityLimit)
                {
                    return(false);
                }
                infos.Add(info);
                return(true);
            }
        }
Example #2
0
        private static SpanDto ToSpanDto([NotNull] TraceContextInfo traceContextInfo)
        {
            var annotations = traceContextInfo.Annotations.ToDictionary(x => x.Key, x => x.Value);

            if (!string.IsNullOrEmpty(traceContextInfo.ContextName) && !traceContextInfo.Annotations.ContainsKey("targetId"))
            {
                annotations["targetId"] = traceContextInfo.ContextName;
            }
            if (traceContextInfo.IsRoot)
            {
                annotations["root"] = "true";
            }
            return(new SpanDto
            {
                TraceId = traceContextInfo.TraceId,
                SpanId = traceContextInfo.ContextId,
                ParentSpanId = traceContextInfo.ParentContextId,
                Timeline = traceContextInfo.Timeline.ToDictionary(x => x.Key, x => x.Value),
                Annotations = annotations,
            });
        }
Example #3
0
 public RealTraceContext([NotNull] string traceId, [NotNull] string contextId, [CanBeNull] string contextName, [CanBeNull] string parentContextId, [NotNull] ITracingEnvironment tracingEnvironment, bool isRoot)
 {
     this.tracingEnvironment  = tracingEnvironment;
     traceContextInfo         = new TraceContextInfo(isRoot, traceId, contextId, contextName, parentContextId);
     previousRealTraceContext = TraceContext.Current as RealTraceContext;
 }