etcdserver/api/v2stats/queue.go
func (q *statsQueue) Rate() (float64, float64) {
	front, back := q.frontAndBack()

	if front == nil || back == nil {
		return 0, 0
	}

	if time.Since(back.SendingTime) > time.Second {
		q.Clear()
		return 0, 0
	}

	sampleDuration := back.SendingTime.Sub(front.SendingTime)

	pr := float64(q.Len()) / float64(sampleDuration) * float64(time.Second)

	br := float64(q.ReqSize()) / float64(sampleDuration) * float64(time.Second)

	return pr, br
}
func (q *statsQueue) Rate() (float64, float64) {
	front, back := q.frontAndBack()

	if front == nil || back == nil {
		return 0, 0
	}

	if time.Since(back.SendingTime) > time.Second {
		q.Clear()
		return 0, 0
	}

	sampleDuration := back.SendingTime.Sub(front.SendingTime)

	pr := float64(q.Len()) / float64(sampleDuration) * float64(time.Second)

	br := float64(q.ReqSize()) / float64(sampleDuration) * float64(time.Second)

	return pr, br
}
// Rate function returns the package rate and byte rate