public void Dispose() { if (Span != null) { Span.DurationInMicroseconds = TickClock.GetDuration(_start); TraceContextPropagation.PopSpan(); ZipkinConfig.Record(Span); Span = null; } }
public StartServerTrace(string name, TraceInfo?traceInfo) { if (traceInfo.HasValue) { this._start = TickClock.Start(); this.Span = new Span(traceInfo.Value.span.TraceId, name, RandomHelper.NewId()) { ParentId = traceInfo.Value.span.ParentId }; this.TimeAnnotateWith(PredefinedTag.ServerRecv); TraceContextPropagation.PushSpan(this.Span); } else { this.Span = null; this._start = 0; } }
/// <summary> /// Creates a local span. /// Give it a short lower-case description of the activity /// </summary> /// <param name="name"></param> public LocalTrace(string name) { if (TraceContextPropagation.IsWithinTrace) { var parentSpan = TraceContextPropagation.CurrentSpan; this.Span = new Span(parentSpan.TraceId, name, RandomHelper.NewId()) { ParentId = parentSpan.Id }; this._start = TickClock.Start(); TraceContextPropagation.PushSpan(this.Span); } else { this.Span = null; this._start = 0; } }
/// <summary> /// Starts a client trace. /// The <see cref="StandardAnnotationKeys.ClientSend"/> annotation is added by default. /// Give it a short lower-case description of the activity /// </summary> public StartClientTrace(string name, bool isDebug = false) { _skipDuration = false; var shouldSample = isDebug || ZipkinConfig.ShouldSample(); if (shouldSample) { this._start = TickClock.Start(); this.Span = new Span(RandomHelper.NewId(), name, RandomHelper.NewId()) { IsDebug = isDebug }; this.TimeAnnotateWith(PredefinedTag.ClientSend); TraceContextPropagation.PushSpan(this.Span); } else { this._start = 0; this.Span = null; } }
public StartServerTrace(string name, IDictionary <string, string> crossProcessContext) : this(name, TraceContextPropagation.GetTraceInfoFrom(crossProcessContext)) { }