Skip to content

Commit

Permalink
Use registerer for gRPC opts and endpoints
Browse files Browse the repository at this point in the history
The EndpointSet and StoreGRPC options accept concrete *prometheus.Registry type.
This makes it hard to create multiple instances of them because they will try
to register the same metrics and the registry will panic.

This commit changes the type to a prometheus.Registerer which allows clients
to inject a prefixed registry and get metrics for each instance.

Signed-off-by: Filip Petkovski <filip.petkovsky@gmail.com>
  • Loading branch information
fpetkovski committed Dec 8, 2023
1 parent 5d4fc6d commit 047f4d9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/extgrpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func EndpointGroupGRPCOpts() []grpc.DialOption {
}

// StoreClientGRPCOpts creates gRPC dial options for connecting to a store client.
func StoreClientGRPCOpts(logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, secure, skipVerify bool, cert, key, caCert, serverName string) ([]grpc.DialOption, error) {
func StoreClientGRPCOpts(logger log.Logger, reg prometheus.Registerer, tracer opentracing.Tracer, secure, skipVerify bool, cert, key, caCert, serverName string) ([]grpc.DialOption, error) {
grpcMets := grpc_prometheus.NewClientMetrics()
grpcMets.EnableClientHandlingTimeHistogram(
grpc_prometheus.WithHistogramBuckets([]float64{0.001, 0.01, 0.1, 0.3, 0.6, 1, 3, 6, 9, 20, 30, 60, 90, 120, 240, 360, 720}),
Expand Down
2 changes: 1 addition & 1 deletion pkg/query/endpointset.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ type nowFunc func() time.Time
func NewEndpointSet(
now nowFunc,
logger log.Logger,
reg *prometheus.Registry,
reg prometheus.Registerer,
endpointSpecs func() []*GRPCEndpointSpec,
dialOpts []grpc.DialOption,
unhealthyEndpointTimeout time.Duration,
Expand Down

0 comments on commit 047f4d9

Please sign in to comment.