code: func (r *sampleRing) add(t int64, v float64) {
  	l := len(r.buf)
  	// Grow the ring buffer if it fits no more elements.
  	if l == r.l {
  		buf := make([]sample, 2*l)
  		copy(buf[l+r.f:], r.buf[r.f:])
  		copy(buf, r.buf[:r.f])
  
  		r.buf = buf
  		r.i = r.f
  		r.f += l
  	} else {
  		r.i++
  		if r.i >= l {
  			r.i -= l
  		}
  	}
  
  	r.buf[r.i] = sample{t: t, v: v}
  	r.l++
  
  	// Free head of the buffer of samples that just fell out of the range.
  	for r.buf[r.f].t < t-r.delta {
  		r.f++
  		if r.f >= l {
  			r.f -= l
  		}
  		r.l--
  	}
  }
docs: // add adds a sample to the ring buffer and frees all samples that fall
  // out of the delta range.