Browse Source

Intermediate changes

robot-piglet 1 year ago
parent
commit
e86f906e85

+ 1 - 1
library/go/core/metrics/prometheus/registry.go

@@ -16,7 +16,7 @@ var _ metrics.Registry = (*Registry)(nil)
 var _ metrics.MetricsStreamer = (*Registry)(nil)
 
 type Registry struct {
-	rg *prometheus.Registry
+	rg PrometheusRegistry
 
 	m             *sync.Mutex
 	subregistries map[string]*Registry

+ 7 - 2
library/go/core/metrics/prometheus/registry_opts.go

@@ -10,10 +10,15 @@ import (
 	"github.com/ydb-platform/ydb/library/go/core/metrics/internal/pkg/registryutil"
 )
 
+type PrometheusRegistry interface {
+	prometheus.Registerer
+	prometheus.Gatherer
+}
+
 type RegistryOpts struct {
 	Prefix        string
 	Tags          map[string]string
-	rg            *prometheus.Registry
+	rg            PrometheusRegistry
 	Collectors    []func(metrics.Registry)
 	NameSanitizer func(string) string
 	StreamFormat  expfmt.Format
@@ -58,7 +63,7 @@ func (o *RegistryOpts) AppendPrefix(prefix string) *RegistryOpts {
 //
 // This is primarily used to unite externally defined metrics with metrics kept
 // in the core registry.
-func (o *RegistryOpts) SetRegistry(rg *prometheus.Registry) *RegistryOpts {
+func (o *RegistryOpts) SetRegistry(rg PrometheusRegistry) *RegistryOpts {
 	o.rg = rg
 	return o
 }