Skip to content

Commit

Permalink
Add metric for current task-runner version (#124)
Browse files Browse the repository at this point in the history
* Add metric for current task-runner version

* Switch from Counter -> Gauge
  • Loading branch information
thomshutt authored Jan 10, 2023
1 parent f8476a1 commit 3becf6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/task-runner/task-runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/livepeer/stream-tester/m3u8"
"github.com/livepeer/task-runner/api"
"github.com/livepeer/task-runner/clients"
"github.com/livepeer/task-runner/metrics"
"github.com/livepeer/task-runner/task"
"github.com/peterbourgon/ff"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -143,6 +144,9 @@ func Run(build BuildFlags) {
cli := parseFlags(build)
glog.Infof("Task runner starting... version=%q", build.Version)

// Fire a metric to track which version of task-runner we're running
metrics.Version.WithLabelValues("task-runner", build.Version).Inc()

clients.UserAgent = "livepeer-task-runner/" + build.Version
cli.runnerOpts.LivepeerAPIOptions.UserAgent = clients.UserAgent
cli.serverOpts.APIHandlerOptions.ServerName = clients.UserAgent
Expand Down
7 changes: 7 additions & 0 deletions metrics/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ var (
},
[]string{"api"},
)
Version = Factory.NewGaugeVec(
prometheus.GaugeOpts{
Name: FQName("version"),
Help: "Current Git SHA / Tag that's running. Incremented once on app startup.",
},
[]string{"app", "version"},
)
)

func ObservedHandlerFunc(apiName string, handler http.HandlerFunc) http.Handler {
Expand Down

0 comments on commit 3becf6c

Please sign in to comment.