Skip to content

Commit cd28739

Browse files
author
Mathieu Lecarme
committed
Count runs.
1 parent 34a15f7 commit cd28739

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

run/run.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ import (
88
"github.com/factorysh/microdensity/task"
99
"github.com/factorysh/microdensity/volumes"
1010
"github.com/google/uuid"
11+
"github.com/prometheus/client_golang/prometheus"
12+
"github.com/prometheus/client_golang/prometheus/promauto"
13+
)
14+
15+
var (
16+
serviceRun = promauto.NewCounterVec(prometheus.CounterOpts{
17+
Name: "run_total",
18+
Help: "Total tasks run",
19+
}, []string{"service", "project"})
1120
)
1221

1322
// Context is a run context, with a STDOUT and a STDERR
@@ -86,6 +95,8 @@ func (r *Runner) Run(t *task.Task) (int, error) {
8695
if !found {
8796
return 0, fmt.Errorf("task with id `%s` not found in runner", t.Id)
8897
}
89-
98+
defer serviceRun.With(prometheus.Labels{
99+
"service": t.Service,
100+
"project": t.Project}).Inc()
90101
return ctx.run.Run(ctx.Stdout, ctx.Stderr)
91102
}

0 commit comments

Comments
 (0)