示例#1
0
            public void ConsiderForSampling(SpanBase span)
            {
                var spanEndTime = span.EndTime;

                if (span.Context.TraceOptions.IsSampled)
                {
                    // Need to compare by doing the subtraction all the time because in case of an overflow,
                    // this may never sample again (at least for the next ~200 years). No real chance to
                    // overflow two times because that means the process runs for ~200 years.
                    if (spanEndTime - this.lastSampledTime > timeBetweenSamples)
                    {
                        this.sampledSpansQueue.Add(span);
                        this.lastSampledTime = spanEndTime;
                    }
                }
                else
                {
                    // Need to compare by doing the subtraction all the time because in case of an overflow,
                    // this may never sample again (at least for the next ~200 years). No real chance to
                    // overflow two times because that means the process runs for ~200 years.
                    if (spanEndTime - this.lastNotSampledTime > timeBetweenSamples)
                    {
                        this.notSampledSpansQueue.Add(span);
                        this.lastNotSampledTime = spanEndTime;
                    }
                }
            }
            public void ConsiderForSampling(SpanBase span)
            {
                long spanEndNanoTime = span.EndNanoTime;

                if (span.Context.TraceOptions.IsSampled)
                {
                    // Need to compare by doing the subtraction all the time because in case of an overflow,
                    // this may never sample again (at least for the next ~200 years). No real chance to
                    // overflow two times because that means the process runs for ~200 years.
                    if (spanEndNanoTime - lastSampledNanoTime > TIME_BETWEEN_SAMPLES)
                    {
                        sampledSpansQueue.Add(span);
                        lastSampledNanoTime = spanEndNanoTime;
                    }
                }
                else
                {
                    // Need to compare by doing the subtraction all the time because in case of an overflow,
                    // this may never sample again (at least for the next ~200 years). No real chance to
                    // overflow two times because that means the process runs for ~200 years.
                    if (spanEndNanoTime - lastNotSampledNanoTime > TIME_BETWEEN_SAMPLES)
                    {
                        notSampledSpansQueue.Add(span);
                        lastNotSampledNanoTime = spanEndNanoTime;
                    }
                }
            }
示例#3
0
        public override void OnStart(ISpan span)
        {
            SpanBase spanBase = span as SpanBase;

            if (spanBase != null)
            {
                runningSpans.AddElement(spanBase);
            }
        }
示例#4
0
        public override void OnEnd(ISpan span)
        {
            SpanBase spanBase = span as SpanBase;

            if (spanBase != null)
            {
                runningSpans.RemoveElement(spanBase);
            }
        }
        public override void SpanFinished(SpanBase span)
        {
            var typedSpan = (ZipkinSpan)span;

            if (typedSpan.TypedContext.Sampled)
            {
                _reporter.Report(span);
            }
        }
            public void ConsiderForSampling(SpanBase span)
            {
                Status status = span.Status;

                // Null status means running Span, this should not happen in production, but the library
                // should not crash because of this.
                if (status != null)
                {
                    Bucket bucket =
                        status.IsOk
                            ? GetLatencyBucket(span.LatencyNs)
                            : GetErrorBucket(status.CanonicalCode);
                    // If unable to find the bucket, ignore this Span.
                    if (bucket != null)
                    {
                        bucket.ConsiderForSampling(span);
                    }
                }
            }
        public override void ConsiderForSampling(ISpan ispan)
        {
            SpanBase span = ispan as SpanBase;

            if (span != null)
            {
                lock (samples)
                {
                    string spanName = span.Name;
                    if (span.IsSampleToLocalSpanStore && !samples.ContainsKey(spanName))
                    {
                        samples[spanName] = new PerSpanNameSamples();
                    }
                    samples.TryGetValue(spanName, out PerSpanNameSamples perSpanNameSamples);
                    if (perSpanNameSamples != null)
                    {
                        perSpanNameSamples.ConsiderForSampling(span);
                    }
                }
            }
        }
示例#8
0
 public override void SpanFinished(SpanBase span)
 {
     FinishedSpans.Add((TestSpan)span);
 }
 public void OnEnd(SpanBase span)
 {
     sampleStore.ConsiderForSampling(span);
 }
 public void OnStart(SpanBase span)
 {
     // Do nothing.
 }