internal Span( Activity activity, Tracestate tracestate, SpanKind spanKind, TraceConfig traceConfig, SpanProcessor spanProcessor, DateTimeOffset startTimestamp, bool ownsActivity) { this.Activity = activity; this.spanContext = new Lazy <SpanContext>(() => SpanContext.Create( this.Activity.TraceId, this.Activity.SpanId, this.Activity.ActivityTraceFlags, tracestate)); this.Name = this.Activity.OperationName; this.traceConfig = traceConfig; this.spanProcessor = spanProcessor; this.Kind = spanKind; this.OwnsActivity = ownsActivity; this.IsRecordingEvents = this.Activity.Recorded; this.startTimestamp = startTimestamp; if (this.IsRecordingEvents) { this.spanProcessor.OnStart(this); } }
internal static ISpan StartSpan( Activity activity, Tracestate tracestate, SpanKind spanKind, ITraceParams traceParams, IStartEndHandler startEndHandler, bool ownsActivity = true) { var span = new Span( activity, tracestate, spanKind, traceParams, startEndHandler, ownsActivity); // Call onStart here instead of calling in the constructor to make sure the span is completely // initialized. if (span.IsRecordingEvents) { startEndHandler.OnStart(span); } return(span); }
private Span( Activity activity, Tracestate tracestate, SpanKind spanKind, ITraceParams traceParams, IStartEndHandler startEndHandler, bool ownsActivity) { this.Activity = activity; this.spanContext = new Lazy <SpanContext>(() => SpanContext.Create( this.Activity.TraceId, this.Activity.SpanId, this.Activity.ActivityTraceFlags, tracestate)); this.Name = this.Activity.OperationName; this.traceParams = traceParams ?? throw new ArgumentNullException(nameof(traceParams)); this.startEndHandler = startEndHandler; this.Kind = spanKind; this.OwnsActivity = ownsActivity; this.IsRecordingEvents = this.Activity.Recorded; }
/// <summary> /// Creates a new <see cref="SpanContext"/> with the given identifiers and options. /// </summary> /// <param name="traceId">The <see cref="ActivityTraceId"/> to associate with the <see cref="SpanContext"/>.</param> /// <param name="spanId">The <see cref="ActivitySpanId"/> to associate with the <see cref="SpanContext"/>.</param> /// <param name="traceOptions">The <see cref="TraceOptions"/> to associate with the <see cref="SpanContext"/>.</param> /// <param name="tracestate">The <see cref="Tracestate"/> to associate with the <see cref="SpanContext"/>.</param> /// <returns>A new <see cref="SpanContext"/> with the given identifiers and options.</returns> public static SpanContext Create(ActivityTraceId traceId, ActivitySpanId spanId, ActivityTraceFlags traceOptions, Tracestate tracestate) { return(new SpanContext(traceId, spanId, traceOptions, tracestate)); }
private SpanContext(ActivityTraceId traceId, ActivitySpanId spanId, ActivityTraceFlags traceOptions, Tracestate tracestate) { this.TraceId = traceId; this.SpanId = spanId; this.TraceOptions = traceOptions; this.Tracestate = tracestate; }