From 8d7be094967fc0318d43f4a6f67ea6b7349e6266 Mon Sep 17 00:00:00 2001 From: Victor Neznaykin Date: Mon, 15 Apr 2024 23:24:23 +0400 Subject: [PATCH] fix grpc metrics --- client/grpc/client.go | 7 ++++--- client/grpc/utils.go | 18 ------------------ 2 files changed, 4 insertions(+), 21 deletions(-) delete mode 100644 client/grpc/utils.go diff --git a/client/grpc/client.go b/client/grpc/client.go index 7abcecd..651dd73 100644 --- a/client/grpc/client.go +++ b/client/grpc/client.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/tx" grpcprom "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus" "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/timeout" + "github.com/prometheus/client_golang/prometheus" "github.com/rs/zerolog" "google.golang.org/grpc" "google.golang.org/grpc/credentials" @@ -50,9 +51,9 @@ func (c *Client) Start(ctx context.Context) error { if c.cfg.MetricsEnabled { cm := grpcprom.NewClientMetrics( - grpcprom.WithClientHandlingTimeHistogram( - grpcprom.WithHistogramBuckets([]float64{0.001, 0.01, 0.1, 0.3, 0.6, 1, 3, 6, 9, 20, 30, 60, 90, 120}), //nolint:lll - )) + grpcprom.WithClientHandlingTimeHistogram()) + + prometheus.MustRegister(cm) options = append( options, diff --git a/client/grpc/utils.go b/client/grpc/utils.go deleted file mode 100644 index ec14361..0000000 --- a/client/grpc/utils.go +++ /dev/null @@ -1,18 +0,0 @@ -package grpc - -import ( - "strconv" - - grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" - "google.golang.org/grpc" - "google.golang.org/grpc/metadata" -) - -// GetHeightRequestHeader returns the grpc.CallOption to query the state at a given height -func GetHeightRequestHeader(height int64) grpc.CallOption { - header := metadata.New(map[string]string{ - grpctypes.GRPCBlockHeightHeader: strconv.FormatInt(height, 10), - }) - - return grpc.Header(&header) -}