public SpanBuilder( [NotNull] TracerSettings settings, [NotNull] IDisposable contextScope, [NotNull] TraceContext currentContext, [CanBeNull] TraceContext parentContext) { this.settings = settings ?? throw new ArgumentNullException(nameof(settings)); this.contextScope = contextScope ?? throw new ArgumentNullException(nameof(contextScope)); metadata = ConstructInitialMetadata(currentContext, parentContext); annotations = ConstructInitialAnnotations(settings); watch = Stopwatch.StartNew(); }
private static SpanMetadata ConstructInitialMetadata([NotNull] TraceContext currentContext, [CanBeNull] TraceContext parentContext) { var beginTimestamp = PreciseDateTime.Now; var endTimestamp = DateTimeOffset.MinValue; var parentSpanId = parentContext?.SpanId; if (parentSpanId == Guid.Empty) { parentSpanId = null; } return(new SpanMetadata( currentContext.TraceId, currentContext.SpanId, parentSpanId, beginTimestamp, endTimestamp)); }
public static IDisposable Use(TraceContext context) { return(TraceContextScope.Begin(context)); }
internal TraceContextScope(TraceContext current, TraceContext parent) { Current = current; Parent = parent; }