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); }