metrics: oblige nitpicks from review

This commit is contained in:
Martin Holst Swende 2023-09-13 07:39:36 +02:00
parent 878680ee23
commit 7d352f8acc
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -83,14 +83,14 @@ func (s *ExpDecaySample) Clear() {
func (s *ExpDecaySample) Snapshot() SampleSnapshot {
s.mutex.Lock()
defer s.mutex.Unlock()
vals := s.values.Values()
values := make([]int64, len(vals))
var (
samples = s.values.Values()
values = make([]int64, len(samples))
max int64 = math.MinInt64
min int64 = math.MaxInt64
sum int64
)
for i, item := range vals {
for i, item := range samples {
v := item.v
values[i] = v
sum += v
@ -196,8 +196,7 @@ type sampleSnapshot struct {
// newSampleSnapshotPrecalculated creates a read-only sampleSnapShot, using
// precalculated sums to avoid iterating the values
func newSampleSnapshotPrecalculated(count int64, values []int64,
min, max, sum int64) *sampleSnapshot {
func newSampleSnapshotPrecalculated(count int64, values []int64, min, max, sum int64) *sampleSnapshot {
if len(values) == 0 {
return &sampleSnapshot{
count: count,