Ejemplo n.º 1
0
 public override bool Equals(Object obj)
 {
     if (obj is TickClock)
     {
         TickClock other = (TickClock)obj;
         return(BaseClock.Equals(other.BaseClock) && TickNanos == other.TickNanos);
     }
     return(false);
 }
Ejemplo n.º 2
0
        public static void ApplyCaptured(TraceInfo capturedContext)
        {
            if (capturedContext.span != null)
            {
                capturedContext.span.DurationInMicroseconds = TickClock.Start();

                PushSpan(capturedContext.span);
            }
        }
Ejemplo n.º 3
0
        public void GetDuration_returns_time_in_microseconds()
        {
            var start = TickClock.Start();

            Thread.Sleep(100);

            var duration = TickClock.GetDuration(start);

            duration.Should().BeInRange(100000, 105000);
        }
Ejemplo n.º 4
0
        public static void UndoApply(TraceInfo capturedContext)
        {
            if (capturedContext.span != null)
            {
                PopSpan();

                capturedContext.span.DurationInMicroseconds = TickClock.GetDuration(capturedContext.span.DurationInMicroseconds.Value);

                ZipkinConfig.Record(capturedContext.span);
            }
        }
Ejemplo n.º 5
0
        public void Dispose()
        {
            if (Span != null)
            {
                Span.DurationInMicroseconds = TickClock.GetDuration(_start);

                TraceContextPropagation.PopSpan();

                ZipkinConfig.Record(Span);

                Span = null;
            }
        }
Ejemplo n.º 6
0
        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;
            }
        }
Ejemplo n.º 7
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;
            }
        }
Ejemplo n.º 8
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;
            }
        }
Ejemplo n.º 9
0
 private void Tick() => TickClock.Tick();