private int deleteOldestTrace() {
    int spansEvicted = 0;
    String lowTraceId = spansByTraceIdTimestamp.delegate.lastKey().lowTraceId;
    Collection<TraceIdTimestamp> traceIdTimeStamps = traceIdToTraceIdTimestamps.remove(lowTraceId);
    for (TraceIdTimestamp traceIdTimeStamp : traceIdTimeStamps) {
      Collection<Span> spans = spansByTraceIdTimestamp.remove(traceIdTimeStamp);
      spansEvicted += spans.size();
    }
    if (searchEnabled) {
      for (String orphanedService : serviceToTraceIds.removeServiceIfTraceId(lowTraceId)) {
        serviceToRemoteServiceNames.remove(orphanedService);
        serviceToSpanNames.remove(orphanedService);
      }
    }
    return spansEvicted;
  }
Returns the count of spans evicted.
zipkin/src/main/java/zipkin2/storage/InMemoryStorage.java