diff --git a/controller/telemetry/metrics.go b/controller/telemetry/metrics.go index 26d4bf5..40f9085 100644 --- a/controller/telemetry/metrics.go +++ b/controller/telemetry/metrics.go @@ -21,6 +21,13 @@ var ( Help: "The invocation duration in seconds for a given function", Buckets: []float64{0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2}, }, labels) + + FunctionBuildCounter = prometheus.NewCounterVec( + prometheus.CounterOpts{ + Namespace: "morty", + Name: "function_build_count", + Help: "The total number of builds", + }, []string{"build_id", "runtime"}) ) // init() will get called on main() function initialization, so @@ -29,4 +36,5 @@ var ( func init() { prometheus.MustRegister(FunctionInvocationCounter) prometheus.MustRegister(FunctionInvocationDurationHistogram) + prometheus.MustRegister(FunctionBuildCounter) } diff --git a/registry/registry/build.go b/registry/registry/build.go index 345a85a..b50697d 100644 --- a/registry/registry/build.go +++ b/registry/registry/build.go @@ -6,6 +6,7 @@ import ( "net/http" "os" + "github.com/morty-faas/morty/controller/telemetry" "github.com/morty-faas/morty/registry/builder" log "github.com/sirupsen/logrus" "golang.org/x/mod/semver" @@ -79,6 +80,8 @@ func (s *Server) BuildHandler(w http.ResponseWriter, r *http.Request) { log.Infof("build/%s: function build successful", opts.Id) + telemetry.FunctionBuildCounter.WithLabelValues(opts.Id, opts.Runtime).Inc() + w.WriteHeader(http.StatusOK) _, _ = w.Write([]byte("/v1/functions/" + functionName + "/" + functionVersion)) }