code: func (tracer *tracerImpl) Flush(ctx context.Context) {
  	tracer.flushingLock.Lock()
  	defer tracer.flushingLock.Unlock()
  
  	if errorEvent := tracer.preFlush(); errorEvent != nil {
  		emitEvent(errorEvent)
  		return
  	}
  
  	if tracer.opts.MetaEventReportingEnabled && !tracer.firstReportHasRun {
  		opentracing.StartSpan(LSMetaEvent_TracerCreateOperation,
  			opentracing.Tag{Key: LSMetaEvent_MetaEventKey, Value: true},
  			opentracing.Tag{Key: LSMetaEvent_TracerGuidKey, Value: tracer.reporterID}).
  			Finish()
  		tracer.firstReportHasRun = true
  	}
  
  	ctx, cancel := context.WithTimeout(ctx, tracer.opts.ReportTimeout)
  	defer cancel()
  
  	req, err := tracer.client.Translate(ctx, &tracer.flushing)
  	if err != nil {
  		errorEvent := newEventFlushError(err, FlushErrorTranslate)
  		emitEvent(errorEvent)
  		// call postflush to prevent the tracer from going into an invalid state.
  		emitEvent(tracer.postFlush(errorEvent))
  		return
  	}
  
  	var reportErrorEvent *eventFlushError
  	resp, err := tracer.client.Report(ctx, req)
  	if err != nil {
  		reportErrorEvent = newEventFlushError(err, FlushErrorTransport)
  	} else if len(resp.GetErrors()) > 0 {
  		reportErrorEvent = newEventFlushError(fmt.Errorf(resp.GetErrors()[0]), FlushErrorReport)
  	}
  
  	if reportErrorEvent != nil {
  		emitEvent(reportErrorEvent)
  	}
  	emitEvent(tracer.postFlush(reportErrorEvent))
  
  	if err == nil && resp.DevMode() {
  		tracer.metaEventReportingEnabled = true
  	}
  
  	if err == nil && !resp.DevMode() {
  		tracer.metaEventReportingEnabled = false
  	}
  
  	if err == nil && resp.Disable() {
  		tracer.Disable()
  	}
  }
docs: // Flush sends all buffered data to the collector.