mirror of
https://github.com/grafana/grafana.git
synced 2025-09-23 00:33:22 +08:00
Metrics: Export multi registry (#97662)
* export multi registry * fixup
This commit is contained in:
@ -66,7 +66,7 @@ func ProvideRegisterer() prometheus.Registerer {
|
|||||||
|
|
||||||
func ProvideGatherer() prometheus.Gatherer {
|
func ProvideGatherer() prometheus.Gatherer {
|
||||||
k8sGatherer := newAddPrefixWrapper(legacyregistry.DefaultGatherer)
|
k8sGatherer := newAddPrefixWrapper(legacyregistry.DefaultGatherer)
|
||||||
return newMultiRegistry(k8sGatherer, prometheus.DefaultGatherer)
|
return NewMultiRegistry(k8sGatherer, prometheus.DefaultGatherer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProvideRegistererForTest() prometheus.Registerer {
|
func ProvideRegistererForTest() prometheus.Registerer {
|
||||||
@ -125,7 +125,7 @@ type multiRegistry struct {
|
|||||||
gatherers []prometheus.Gatherer
|
gatherers []prometheus.Gatherer
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMultiRegistry(gatherers ...prometheus.Gatherer) *multiRegistry {
|
func NewMultiRegistry(gatherers ...prometheus.Gatherer) *multiRegistry {
|
||||||
return &multiRegistry{
|
return &multiRegistry{
|
||||||
gatherers: gatherers,
|
gatherers: gatherers,
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ func TestGathererPrefixWrapper_Gather(t *testing.T) {
|
|||||||
func TestMultiRegistry_Gather(t *testing.T) {
|
func TestMultiRegistry_Gather(t *testing.T) {
|
||||||
one := &mockGatherer{}
|
one := &mockGatherer{}
|
||||||
two := &mockGatherer{}
|
two := &mockGatherer{}
|
||||||
g := newMultiRegistry(one, two)
|
g := NewMultiRegistry(one, two)
|
||||||
|
|
||||||
t.Run("should merge and sort metrics", func(t *testing.T) {
|
t.Run("should merge and sort metrics", func(t *testing.T) {
|
||||||
one.GatherFunc = func() ([]*dto.MetricFamily, error) {
|
one.GatherFunc = func() ([]*dto.MetricFamily, error) {
|
||||||
|
Reference in New Issue
Block a user