Skip to content

Commit

Permalink
kv: add grpc client metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Neil Shen <overvenus@gmail.com>
  • Loading branch information
overvenus committed Jul 14, 2021
1 parent 3692077 commit d2c1aae
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cdc/kv/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ func (a *ConnArray) initLocked(ctx context.Context, target string) error {
grpc.WithInitialWindowSize(grpcInitialWindowSize),
grpc.WithInitialConnWindowSize(grpcInitialConnWindowSize),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(grpcMaxCallRecvMsgSize)),
grpc.WithUnaryInterceptor(grpcMetrics.UnaryClientInterceptor()),
grpc.WithStreamInterceptor(grpcMetrics.StreamClientInterceptor()),
grpc.WithConnectParams(grpc.ConnectParams{
Backoff: gbackoff.Config{
BaseDelay: time.Second,
Expand Down
10 changes: 9 additions & 1 deletion cdc/kv/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@

package kv

import "github.com/prometheus/client_golang/prometheus"
import (
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/prometheus/client_golang/prometheus"
)

var (
grpcMetrics = grpc_prometheus.NewClientMetrics()

eventFeedErrorCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "ticdc",
Expand Down Expand Up @@ -103,4 +108,7 @@ func InitMetrics(registry *prometheus.Registry) {
registry.MustRegister(clientRegionTokenSize)
registry.MustRegister(batchResolvedEventSize)
registry.MustRegister(etcdRequestCounter)

// Register client metrics to registry.
registry.MustRegister(grpcMetrics)
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/google/btree v1.0.0
github.com/google/go-cmp v0.5.4
github.com/google/uuid v1.1.1
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/grpc-ecosystem/grpc-gateway v1.14.3 // indirect
github.com/integralist/go-findroot v0.0.0-20160518114804-ac90681525dc
github.com/jarcoal/httpmock v1.0.5
Expand Down

0 comments on commit d2c1aae

Please sign in to comment.