~comcloudway/builds.sr.ht

2614bc0cb7bad10e35e13838602baa5f2f82b61f — Ignas Kiela 2 years ago c24f2c2
api: instrument build submissions
2 files changed, 11 insertions(+), 0 deletions(-)

M api/go.mod
M api/graph/celery.go
M api/go.mod => api/go.mod +1 -0
@@ 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
)

M api/graph/celery.go => api/graph/celery.go +10 -0
@@ 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
}