code: func (tracer *tracerImpl) preFlush() *eventFlushError {
  	tracer.lock.Lock()
  	defer tracer.lock.Unlock()
  
  	if tracer.disabled {
  		return newEventFlushError(errFlushFailedTracerClosed, FlushErrorTracerDisabled)
  	}
  
  	if tracer.connection == nil {
  		return newEventFlushError(errFlushFailedTracerClosed, FlushErrorTracerClosed)
  	}
  
  	now := time.Now()
  	tracer.buffer, tracer.flushing = tracer.flushing, tracer.buffer
  	tracer.reportInFlight = true
  	tracer.flushing.setFlushing(now)
  	tracer.buffer.setCurrent(now)
  	tracer.lastReportAttempt = now
  	return nil
  }
docs: // preFlush handles lock-protected data manipulation before flushing