From 3f8e065947fe6054e5ad51d567a371524af3c784 Mon Sep 17 00:00:00 2001 From: Rohit Jnagal Date: Thu, 23 Jul 2015 01:56:07 +0000 Subject: [PATCH] Two small fixes to custom metric collection. - a typo in minPollingFrequency multiplies it with time.Second twice. - Updating custom metrics is unnecessarily called for all containers. --- collector/generic_collector.go | 2 +- manager/container.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/collector/generic_collector.go b/collector/generic_collector.go index 6f4446d5..289274e9 100644 --- a/collector/generic_collector.go +++ b/collector/generic_collector.go @@ -100,7 +100,7 @@ func (collector *GenericCollector) Name() string { //Returns collected metrics and the next collection time of the collector func (collector *GenericCollector) Collect() (time.Time, []v1.Metric, error) { currentTime := time.Now() - nextCollectionTime := currentTime.Add(time.Duration(collector.info.minPollingFrequency * time.Second)) + nextCollectionTime := currentTime.Add(time.Duration(collector.info.minPollingFrequency)) uri := collector.configFile.Endpoint response, err := http.Get(uri) diff --git a/manager/container.go b/manager/container.go index 46c2251b..a6744452 100644 --- a/manager/container.go +++ b/manager/container.go @@ -486,8 +486,8 @@ func (c *containerData) updateStats() error { } } var customStatsErr error - if c.collectorManager != nil { - cm := c.collectorManager.(*collector.GenericCollectorManager) + cm := c.collectorManager.(*collector.GenericCollectorManager) + if len(cm.Collectors) > 0 { if cm.NextCollectionTime.Before(time.Now()) { customStats, err := c.updateCustomStats() if customStats != nil {