From 81243536a9e588e87bceda9894b4d0267d5f06b6 Mon Sep 17 00:00:00 2001 From: Yuki Watanabe <47182350+yuki0920@users.noreply.github.com> Date: Sat, 2 Dec 2023 06:57:38 +0900 Subject: [PATCH] Replace deplecated function in otelgrpc for go (#1284) --- src/checkoutservice/main.go | 6 ++---- src/productcatalogservice/main.go | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/checkoutservice/main.go b/src/checkoutservice/main.go index 847514b352..1b427882c6 100644 --- a/src/checkoutservice/main.go +++ b/src/checkoutservice/main.go @@ -181,8 +181,7 @@ func main() { } var srv = grpc.NewServer( - grpc.UnaryInterceptor(otelgrpc.UnaryServerInterceptor()), - grpc.StreamInterceptor(otelgrpc.StreamServerInterceptor()), + grpc.StatsHandler(otelgrpc.NewServerHandler()), ) pb.RegisterCheckoutServiceServer(srv, svc) healthpb.RegisterHealthServer(srv, svc) @@ -343,8 +342,7 @@ func (cs *checkoutService) prepareOrderItemsAndShippingQuoteFromCart(ctx context func createClient(ctx context.Context, svcAddr string) (*grpc.ClientConn, error) { return grpc.DialContext(ctx, svcAddr, grpc.WithTransportCredentials(insecure.NewCredentials()), - grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor()), - grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor()), + grpc.WithStatsHandler(otelgrpc.NewClientHandler()), ) } diff --git a/src/productcatalogservice/main.go b/src/productcatalogservice/main.go index a8bb74f5c4..4063c1869d 100644 --- a/src/productcatalogservice/main.go +++ b/src/productcatalogservice/main.go @@ -141,8 +141,7 @@ func main() { } srv := grpc.NewServer( - grpc.UnaryInterceptor(otelgrpc.UnaryServerInterceptor()), - grpc.StreamInterceptor(otelgrpc.StreamServerInterceptor()), + grpc.StatsHandler(otelgrpc.NewServerHandler()), ) reflection.Register(srv) @@ -278,7 +277,6 @@ func (p *productCatalog) checkProductFailure(ctx context.Context, id string) boo func createClient(ctx context.Context, svcAddr string) (*grpc.ClientConn, error) { return grpc.DialContext(ctx, svcAddr, grpc.WithTransportCredentials(insecure.NewCredentials()), - grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor()), - grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor()), + grpc.WithStatsHandler(otelgrpc.NewClientHandler()), ) }