Skip to content

Commit

Permalink
enables scheduler metrics
Browse files Browse the repository at this point in the history
this replaces prometheus client_golang default
collector with one that includes Go scheduler metrics
  • Loading branch information
vroldanbet committed Oct 25, 2023
1 parent dae4587 commit 21b85c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/spicedb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
17 changes: 17 additions & 0 deletions pkg/runtime/metrics.go
Original file line number Diff line number Diff line change
@@ -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),
))
}

0 comments on commit 21b85c7

Please sign in to comment.