public override bool Equals(Object obj) { if (obj is TickClock) { TickClock other = (TickClock)obj; return(BaseClock.Equals(other.BaseClock) && TickNanos == other.TickNanos); } return(false); }
public static void ApplyCaptured(TraceInfo capturedContext) { if (capturedContext.span != null) { capturedContext.span.DurationInMicroseconds = TickClock.Start(); PushSpan(capturedContext.span); } }
public void GetDuration_returns_time_in_microseconds() { var start = TickClock.Start(); Thread.Sleep(100); var duration = TickClock.GetDuration(start); duration.Should().BeInRange(100000, 105000); }
public static void UndoApply(TraceInfo capturedContext) { if (capturedContext.span != null) { PopSpan(); capturedContext.span.DurationInMicroseconds = TickClock.GetDuration(capturedContext.span.DurationInMicroseconds.Value); ZipkinConfig.Record(capturedContext.span); } }
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; } }
private void Tick() => TickClock.Tick();