Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions pkg/metrics/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ limitations under the License.

package metrics

import "github.com/prometheus/client_golang/prometheus"
import (
"regexp"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
)

// RegistererGatherer combines both parts of the API of a Prometheus
// registry, both the Registerer and the Gatherer interfaces.
Expand All @@ -27,4 +32,22 @@ type RegistererGatherer interface {

// Registry is a prometheus registry for storing metrics within the
// controller-runtime.
var Registry RegistererGatherer = prometheus.NewRegistry()
var Registry RegistererGatherer = NewRegistry()

func NewRegistry() *prometheus.Registry {
r := prometheus.NewRegistry()

// default registers
r.MustRegister(
collectors.NewGoCollector(
collectors.WithGoCollectorRuntimeMetrics(
collectors.MetricsGC,
collectors.MetricsScheduler,
collectors.MetricsMemory,
collectors.GoRuntimeMetricsRule{Matcher: regexp.MustCompile(`^/sync/.*`)},
),
),
collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}),
)
return r
}
Loading