public bool TryAdd([NotNull] TraceContextInfo info) { var capacityLimit = configProvider.GetConfig().MaxBufferedSpans; lock (syncObject) { if (infos.Count >= capacityLimit) { return(false); } infos.Add(info); return(true); } }
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, }); }
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; }