From 2614bc0cb7bad10e35e13838602baa5f2f82b61f Mon Sep 17 00:00:00 2001 From: Ignas Kiela Date: Mon, 13 Dec 2021 17:16:01 +0200 Subject: [PATCH] api: instrument build submissions --- api/go.mod | 1 + api/graph/celery.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/api/go.mod b/api/go.mod index c671489..80eb95e 100644 --- a/api/go.mod +++ b/api/go.mod @@ -9,6 +9,7 @@ require ( github.com/gocelery/gocelery v0.0.0-20201111034804-825d89059344 // indirect github.com/google/uuid v1.0.0 // indirect github.com/lib/pq v1.8.0 // indirect + github.com/prometheus/client_golang v1.11.0 // indirect github.com/vektah/gqlparser/v2 v2.1.0 gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/api/graph/celery.go b/api/graph/celery.go index 9cb7b94..991c5b3 100644 --- a/api/graph/celery.go +++ b/api/graph/celery.go @@ -6,6 +6,15 @@ import ( "git.sr.ht/~sircmpwn/core-go/config" celery "github.com/gocelery/gocelery" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promauto" +) + +var ( + buildsSubmitted = promauto.NewCounter(prometheus.CounterOpts{ + Name: "buildsrht_builds_submited_total", + Help: "Number of builds submitted", + }) ) func SubmitJob(ctx context.Context, jobID int, manifest *Manifest) error { @@ -22,6 +31,7 @@ func SubmitJob(ctx context.Context, jobID int, manifest *Manifest) error { } + buildsSubmitted.Inc() _, err = client.Delay("buildsrht.runner.run_build", jobID, manifest) return err } -- 2.38.5