private void DumpEntries(object state) { while (!this.cancellationToken.IsCancellationRequested) { var spans = new List <SpanData>(); RedisProfilerEntryToSpanConverter.DrainSession(null, this.defaultSession.FinishProfiling(), this.sampler, spans); foreach (var entry in this.cache) { var span = entry.Key; if (span.HasEnded) { this.cache.TryRemove(span, out var session); RedisProfilerEntryToSpanConverter.DrainSession(span, session.FinishProfiling(), this.sampler, spans); } else { this.cache.TryGetValue(span, out var session); RedisProfilerEntryToSpanConverter.DrainSession(span, session.FinishProfiling(), this.sampler, spans); } } foreach (var s in spans) { this.exporter.SpanExporter.ExportAsync(s, CancellationToken.None).Wait(); } Thread.Sleep(TimeSpan.FromSeconds(1)); } }
private void DumpEntries(object state) { while (!this.cancellationToken.IsCancellationRequested) { RedisProfilerEntryToSpanConverter.DrainSession(this.tracer, null, this.defaultSession.FinishProfiling()); foreach (var entry in this.cache) { var span = entry.Key; ProfilingSession session; // Redis instrumentation needs a hack to know that current span has ended (it's not tracing-friendly) var endTimestamp = (DateTimeOffset)this.spanEndTimestampInfo.GetValue(span); if (endTimestamp != default) { this.cache.TryRemove(span, out session); } else { this.cache.TryGetValue(span, out session); } if (session != null) { RedisProfilerEntryToSpanConverter.DrainSession(this.tracer, span, session.FinishProfiling()); } } Thread.Sleep(TimeSpan.FromSeconds(1)); } }
private void DumpEntries(object state) { while (!this.cancellationToken.IsCancellationRequested) { RedisProfilerEntryToSpanConverter.DrainSession(this.tracer, null, this.defaultSession.FinishProfiling()); foreach (var entry in this.cache) { var span = entry.Key; ProfilingSession session; if (span.HasEnded) { this.cache.TryRemove(span, out session); } else { this.cache.TryGetValue(span, out session); } if (session != null) { RedisProfilerEntryToSpanConverter.DrainSession(this.tracer, span, session.FinishProfiling()); } } Thread.Sleep(TimeSpan.FromSeconds(1)); } }
private void DumpEntries(object state) { while (!this.cancellationToken.IsCancellationRequested) { RedisProfilerEntryToSpanConverter.DrainSession(this.tracer, null, this.defaultSession.FinishProfiling()); foreach (var entry in this.cache) { var span = entry.Key; ProfilingSession session; // TODO expose end timestamp on ISpan (needed anyway) and use it as indicator that span has ended. // after that, Redis can depend on abstractions if (span is Span spanImpl && spanImpl.EndTimestamp != default) { this.cache.TryRemove(span, out session); }