From 9bf9ad16cac5a5aa16fb6aae595dc425ab15e585 Mon Sep 17 00:00:00 2001 From: "minquan.chen" Date: Mon, 5 Dec 2022 11:38:28 +0800 Subject: [PATCH] add otel interceptor Signed-off-by: minquan.chen --- pkg/apiclient/apiclient.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/apiclient/apiclient.go b/pkg/apiclient/apiclient.go index a7b7ca5ee758e..9b90e0ecca667 100644 --- a/pkg/apiclient/apiclient.go +++ b/pkg/apiclient/apiclient.go @@ -22,6 +22,7 @@ import ( grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry" retryablehttp "github.com/hashicorp/go-retryablehttp" log "github.com/sirupsen/logrus" + "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" "golang.org/x/oauth2" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -523,6 +524,8 @@ func (c *client) newConn() (*grpc.ClientConn, io.Closer, error) { dialOpts = append(dialOpts, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(MaxGRPCMessageSize), grpc.MaxCallSendMsgSize(MaxGRPCMessageSize))) dialOpts = append(dialOpts, grpc.WithStreamInterceptor(grpc_retry.StreamClientInterceptor(retryOpts...))) dialOpts = append(dialOpts, grpc.WithUnaryInterceptor(grpc_middleware.ChainUnaryClient(grpc_retry.UnaryClientInterceptor(retryOpts...)))) + dialOpts = append(dialOpts, grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor())) + dialOpts = append(dialOpts, grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor())) ctx := context.Background()