func (b *bucket) size() int {
	if b.overflow {
		return len(b.buffer)
	}
	return b.nextIndex
}
size returns the number of spans in the bucket.
package trace
import (
	"time"
)
const samplePeriod = time.Second
var defaultLatencies = [...]time.Duration{
	10 * time.Microsecond,
	100 * time.Microsecond,
	time.Millisecond,
	10 * time.Millisecond,
	100 * time.Millisecond,
	time.Second,
	10 * time.Second,
	time.Minute,
}
type bucket struct {
	nextTime  time.Time    
	buffer    []*SpanData  
	nextIndex int          
	overflow  bool         
}
func makeBucket(bufferSize int) bucket {
	return bucket{
		buffer: make([]*SpanData, bufferSize),
	}
}
func (b *bucket) add(s *SpanData) {
	if s.EndTime.Before(b.nextTime) {
		return
	}
	if len(b.buffer) == 0 {
		return
	}
	b.nextTime = s.EndTime.Add(samplePeriod)
	b.buffer[b.nextIndex] = s
	b.nextIndex++
	if b.nextIndex == len(b.buffer) {
		b.nextIndex = 0
		b.overflow = true
	}
}