Skip to content
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

Correctly handle 400 Bad Request and 404 Not Found in gRPC streaming #4144

Merged
merged 6 commits into from
Oct 1, 2024

Conversation

mapno
Copy link
Member

@mapno mapno commented Sep 30, 2024

What this PR does:

Correctly handle 400 Bad Request and 404 Not Found in gRPC streaming.

Status codes in gRPC are changed to return InvalidArgument for 400 and NotFound for 404. Other non-special HTTP status codes are Unknown.

This also allows fixing how 400 responses are counted towards SLO calculations.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Copy link
Member

@joe-elliott joe-elliott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one comment to just add the logging logic to all the streaming handlers, but other than that lgTm

@@ -139,6 +139,8 @@ func logResult(logger log.Logger, tenantID string, durationSeconds float64, req
statusCode := -1
if httpResp != nil {
statusCode = httpResp.StatusCode
} else if st, ok := status.FromError(err); ok {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is httpResp nil in this case?

we may also want to add this same logic to the other log methods

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other handlers use a simpler logic that's not affected by that.

@mapno mapno changed the title Correctly handle 400 Bad Request in gRPC streaming Correctly handle 400 Bad Request and 404 Not Found in gRPC streaming Oct 1, 2024
@mapno mapno merged commit 37cd120 into grafana:main Oct 1, 2024
16 checks passed
@mapno mapno deleted the fix-streaming-400 branch October 1, 2024 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants