diff --git a/cmd/spicedb/main.go b/cmd/spicedb/main.go index ba0977a20b..edca7049cd 100644 --- a/cmd/spicedb/main.go +++ b/cmd/spicedb/main.go @@ -14,6 +14,7 @@ import ( "github.com/authzed/spicedb/pkg/cmd" cmdutil "github.com/authzed/spicedb/pkg/cmd/server" "github.com/authzed/spicedb/pkg/cmd/testserver" + _ "github.com/authzed/spicedb/pkg/runtime" "github.com/authzed/spicedb/pkg/spiceerrors" ) diff --git a/pkg/runtime/metrics.go b/pkg/runtime/metrics.go new file mode 100644 index 0000000000..85f0f8a98f --- /dev/null +++ b/pkg/runtime/metrics.go @@ -0,0 +1,17 @@ +package runtime + +import ( + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/collectors" +) + +// prometheus client_golang by default registers a collector that collects all metrics, except scheduler metrics +// this package unregisters the default collector and adds one that includes scheduler metrics +// +// in order to register this, the package must be imported anonymously +func init() { + prometheus.DefaultRegisterer.Unregister(collectors.NewGoCollector()) + prometheus.MustRegister(collectors.NewGoCollector( + collectors.WithGoCollectorRuntimeMetrics(collectors.MetricsAll), + )) +}