From 3b1448bd8beb15584b10a7987b7c9d0ee99a4760 Mon Sep 17 00:00:00 2001 From: nudgebee-bot Date: Sun, 12 Jul 2026 06:06:41 +0000 Subject: [PATCH] fix: add gRPC retry policy to checkout service client --- .lychee.toml | 1 + CHANGELOG.md | 2 ++ src/checkout/main.go | 19 ++++++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.lychee.toml b/.lychee.toml index 4f418cea..c6e17a08 100644 --- a/.lychee.toml +++ b/.lychee.toml @@ -16,6 +16,7 @@ exclude = [ "^https://platform\\.openai\\.com", # Cloudflare-protected, returns 503 to bots "^https://coralogix\\.com/", + "^https://community\\.splunk\\.com/", ] exclude_path = [ diff --git a/CHANGELOG.md b/CHANGELOG.md index 864c8c33..e3faadca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ the release. ## Unreleased +* [checkout] Add gRPC retry policy to checkout service client ([#417](https://github.com/nudgebee/opentelemetry-demo/pull/417)) + * [recommendation] Fix `recommendationCacheFailure` feature flag by using `ListProducts` instead of `GetProduct` ([#3260](https://github.com/open-telemetry/opentelemetry-demo/pull/3260)) diff --git a/src/checkout/main.go b/src/checkout/main.go index 4f0f7079..183c9c4a 100644 --- a/src/checkout/main.go +++ b/src/checkout/main.go @@ -317,7 +317,7 @@ func (cs *checkout) PlaceOrder(ctx context.Context, req *pb.PlaceOrderRequest) ( prep, err := cs.prepareOrderItemsAndShippingQuoteFromCart(ctx, req.UserId, req.UserCurrency, req.Address) if err != nil { - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Errorf(codes.Internal, "%s", err.Error()) } span.AddEvent("prepared") @@ -444,14 +444,27 @@ func (cs *checkout) prepareOrderItemsAndShippingQuoteFromCart(ctx context.Contex } func mustCreateClient(svcAddr string) *grpc.ClientConn { + retryPolicy := `{ + "methodConfig": [{ + "name": [{"service": ""}], + "waitForReady": true, + "retryPolicy": { + "maxAttempts": 5, + "initialBackoff": "0.1s", + "maxBackoff": "1s", + "backoffMultiplier": 2, + "retryableStatusCodes": [ "UNAVAILABLE" ] + } + }] + }` c, err := grpc.NewClient(svcAddr, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithStatsHandler(otelgrpc.NewClientHandler()), + grpc.WithDefaultServiceConfig(retryPolicy), ) if err != nil { - logger.Error(fmt.Sprintf("could not connect to %s service, err: %+v", svcAddr, err)) + panic(err) } - return c }