// Saves the span data to the batch. If the batch should be sent,
// returns a batch to send.
Saves the span data to the batch. If the batch should be sent,
returns a batch to send.
// Saves the span data to the batch . If the batch should be sent // returns a batch to send .
func (e *Exporter) saveBatch(span *trace.SpanData) []*trace.SpanData {
	var sendBatch []*trace.SpanData
	e.mu.Lock()
	{
		e.batch = append(e.batch, span)
		switch {
		case len(e.batch) == e.batchSize:
			sendBatch = e.batch
			e.batch = make([]*trace.SpanData, 0, e.batchSize)
			e.timer.Reset(e.sendInterval)
		default:
			select {
			case <-e.timer.C:
				sendBatch = e.batch
				e.batch = make([]*trace.SpanData, 0, e.batchSize)
				e.timer.Reset(e.sendInterval)
			default:
			}
		}
	}
	e.mu.Unlock()
	return sendBatch
}
func ( e * Exporter ) saveBatch ( span * trace . SpanData ) [ ] * trace . SpanData { var sendBatch [ ] * trace . SpanData e . mu . Lock ( ) { e . batch = append ( e . batch , span ) switch { case len ( e . batch ) == e . batchSize : sendBatch = e . batch e . batch = make ( [ ] * trace . SpanData , 0 , e . batchSize ) e . timer . Reset ( e . sendInterval ) default : select { case <- e . timer . C : sendBatch = e . batch e . batch = make ( [ ] * trace . SpanData , 0 , e . batchSize ) e . timer . Reset ( e . sendInterval ) default : } } } e . mu . Unlock ( ) return sendBatch }
Saves the span data to the batch.
Saves the span data to the batch .
// We want to append this new span to the collection. // Do we need to send the current batch? // We hit the batch size. Now save the current // batch for sending and start a new batch. // We did not hit the batch size but maybe send what // we have based on time. // The time has expired so save the current // batch for sending and start a new batch. // It's not time yet, just move on.