Don't record the same stat point multiple times

This commit is contained in:
Tim St. Clair
2015-12-09 17:20:34 -08:00
parent e72e819395
commit 2e6ef04aeb

View File

@@ -607,8 +607,13 @@ func (r *resourceCollector) collectStats(oldStats map[string]*cadvisorapi.Contai
Logf("Missing info/stats for container %q on node %q", name, r.node)
return
}
if _, ok := oldStats[name]; ok {
r.buffers[name] = append(r.buffers[name], computeContainerResourceUsage(name, oldStats[name], info.Stats[0]))
if oldInfo, ok := oldStats[name]; ok {
newInfo := info.Stats[0]
if oldInfo.Timestamp.Equal(newInfo.Timestamp) {
// No change -> skip this stat.
continue
}
r.buffers[name] = append(r.buffers[name], computeContainerResourceUsage(name, oldInfo, newInfo))
}
oldStats[name] = info.Stats[0]
}