Skip to content

Commit

Permalink
Fix task duration
Browse files Browse the repository at this point in the history
  • Loading branch information
frodenas committed May 2, 2017
1 parent 19f0a4d commit e97beb6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions collectors/tasks_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ func (c TasksCollector) reportTasksMetrics(ch chan<- prometheus.Metric) error {

if !task.StartedAt.IsZero() && !task.StoppedAt.IsZero() {
duration := task.StoppedAt.Time().Unix() - task.StartedAt.Time().Unix()
if duration > 0 {
durationSeconds := float64(duration) / float64(time.Second)
c.tasksDurationSecondsMetric.WithLabelValues(task.Op, task.Status).Observe(durationSeconds)
if duration >= 0 {
c.tasksDurationSecondsMetric.WithLabelValues(task.Op, task.Status).Observe(float64(duration))
}
}
}
Expand Down

0 comments on commit e97beb6

Please sign in to comment.