Merge pull request #335 from shmsr/dup-init-vars

Avoid double initialization of variables
This commit is contained in:
Matthias Rampke 2020-09-07 09:38:12 +02:00 committed by GitHub
commit da85f9d207
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -107,18 +107,20 @@ func (r *Registry) Store(metricName string, hash metrics.LabelHash, labels prome
metric.Vectors[hash.Names] = v
}
now := clock.Now()
rm, ok := metric.Metrics[hash.Values]
if !ok {
rm = &metrics.RegisteredMetric{
Labels: labels,
TTL: ttl,
Metric: mh,
VecKey: hash.Names,
LastRegisteredAt: now,
Labels: labels,
TTL: ttl,
Metric: mh,
VecKey: hash.Names,
}
metric.Metrics[hash.Values] = rm
v.RefCount++
return
}
now := clock.Now()
rm.LastRegisteredAt = now
// Update ttl from mapping
rm.TTL = ttl