-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[ProductCatalogService] Add product catalog service problem patterns #1382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
4592242
0a93be9
70bc2fd
600fc5a
f898f6c
96969b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,6 +217,13 @@ func (p *productCatalog) Watch(req *healthpb.HealthCheckRequest, ws healthpb.Hea | |
func (p *productCatalog) ListProducts(ctx context.Context, req *pb.Empty) (*pb.ListProductsResponse, error) { | ||
span := trace.SpanFromContext(ctx) | ||
|
||
if p.getFeatureFlag(ctx, "ItemListInternal") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How would a 500 error happen here naturally? Is there a better way to represent this failure scenario? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This 500 error is initially meant to be in the SearchProducts endpoint, but that is not called by anything, thats why I moved this to here to be able to throw an Internal error in a Go service, so we can demonstrate the detection of that. |
||
msg := fmt.Sprintf("ItemListInternal flag enabled! List failed!") | ||
span.SetStatus(otelcodes.Error, msg) | ||
span.AddEvent(msg) | ||
return nil, status.Errorf(codes.Internal, msg) | ||
} | ||
|
||
span.SetAttributes( | ||
attribute.Int("app.products.count", len(catalog)), | ||
) | ||
|
@@ -237,6 +244,13 @@ func (p *productCatalog) GetProduct(ctx context.Context, req *pb.GetProductReque | |
return nil, status.Errorf(codes.Internal, msg) | ||
} | ||
|
||
if p.getFeatureFlag(ctx, "ItemNotFound") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit confused by this failure case -- do we need to force it via flag? Wouldn't simply passing an invalid product ID to the service trigger the same result as this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The flag would still need to be in place to control when to send the wrong id, but yeah, agree with you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmmm, validating the PR I actually understood the scenario. I can see that being used in demos, to showcase errors on a page that is part of the checkout flow.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could move the ItemNotFound logic to loadgenerator to query some clearly invalid products, the requirement from our end is to demonstrate a notfound error in the sample |
||
msg := fmt.Sprintf("ItemNotFound flag enabled! Product Not Found!") | ||
span.SetStatus(otelcodes.Error, msg) | ||
span.AddEvent(msg) | ||
return nil, status.Errorf(codes.NotFound, msg) | ||
} | ||
|
||
var found *pb.Product | ||
for _, product := range catalog { | ||
if req.Id == product.Id { | ||
|
@@ -281,6 +295,11 @@ func (p *productCatalog) checkProductFailure(ctx context.Context, id string) boo | |
return false | ||
} | ||
|
||
return p.getFeatureFlag(ctx, "productCatalogFailure") | ||
} | ||
|
||
func (p *productCatalog) getFeatureFlag(ctx context.Context, flagName string) bool { | ||
|
||
conn, err := createClient(ctx, p.featureFlagSvcAddr) | ||
if err != nil { | ||
span := trace.SpanFromContext(ctx) | ||
|
@@ -289,7 +308,6 @@ func (p *productCatalog) checkProductFailure(ctx context.Context, id string) boo | |
} | ||
defer conn.Close() | ||
|
||
flagName := "productCatalogFailure" | ||
ffResponse, err := pb.NewFeatureFlagServiceClient(conn).GetFlag(ctx, &pb.GetFlagRequest{ | ||
Name: flagName, | ||
}) | ||
|
Uh oh!
There was an error while loading. Please reload this page.