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; } } }
public override void OnStart(ISpan span) { SpanBase spanBase = span as SpanBase; if (spanBase != null) { runningSpans.AddElement(spanBase); } }
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); } } } }
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. }