Skip to content

Commit

Permalink
expose prometheus.Registerer so that we can hook into this from exter…
Browse files Browse the repository at this point in the history
…nal sources

Change-Id: I0b4aa2218e309722a85143a50200e9e105020866
  • Loading branch information
logicalhan committed Dec 5, 2022
1 parent 3e26e10 commit 07f262b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions staging/src/k8s.io/component-base/metrics/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ type KubeRegistry interface {
Reset()
// RegisterMetaMetrics registers metrics about the number of registered metrics.
RegisterMetaMetrics()
// Registerer exposes the underlying prometheus registerer
Registerer() prometheus.Registerer
// Gatherer exposes the underlying prometheus gatherer
Gatherer() prometheus.Gatherer
}

// kubeRegistry is a wrapper around a prometheus registry-type object. Upon initialization
Expand Down Expand Up @@ -188,6 +192,16 @@ func (kr *kubeRegistry) Register(c Registerable) error {
return nil
}

// Registerer exposes the underlying prometheus.Registerer
func (kr *kubeRegistry) Registerer() prometheus.Registerer {
return kr.PromRegistry
}

// Gatherer exposes the underlying prometheus.Gatherer
func (kr *kubeRegistry) Gatherer() prometheus.Gatherer {
return kr.PromRegistry
}

// MustRegister works like Register but registers any number of
// Collectors and panics upon the first registration that causes an
// error.
Expand Down

0 comments on commit 07f262b

Please sign in to comment.