Skip to content

Commit

Permalink
remove the defer time (openstack-exporter#105)
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Niedbalski <[email protected]>
  • Loading branch information
niedbalski authored Jul 2, 2020
1 parent 18f15e3 commit eef90a8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions exporters/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ func (exporter *BaseOpenStackExporter) AddMetricCollectTime(collectTimeSeconds f
func (exporter *BaseOpenStackExporter) RunCollection(metric *PrometheusMetric, metricName string, ch chan<- prometheus.Metric) error {
log.Infof("Collecting metrics for exporter: %s, metric: %s", exporter.GetName(), metricName)
now := time.Now()
if exporter.CollectTime {
defer exporter.AddMetricCollectTime(time.Since(now).Seconds(), metricName, ch)
}
err := metric.Fn(exporter, ch)
if err != nil {
return fmt.Errorf("failed to collect metric: %s, error: %s", metricName, err)
}

log.Infof("Collected metrics for exporter: %s, metric: %s", exporter.GetName(), metricName)
if exporter.CollectTime {
exporter.AddMetricCollectTime(time.Since(now).Seconds(), metricName, ch)
}
return nil
}

Expand Down

0 comments on commit eef90a8

Please sign in to comment.