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

[Question] Middleware appears to use HTTP error codes even when the request was originally gRPC - is this intended? #3442

Closed
wscalf opened this issue Oct 15, 2024 · 3 comments · Fixed by #3447
Labels
question Further information is requested

Comments

@wscalf
Copy link

wscalf commented Oct 15, 2024

While working with the metrics middleware, we noticed that all the error codes showing up in Prometheus were HTTP status codes (400, 504, etc) even though only the gRPC endpoints were being exercised, which surprised us at first, but it looks like all the middlewares behave this way:

  • Kratos errors are declared with an HTTP status code [link]
  • And middlewares use this code field directly (metrics, logging)

Which left us wondering: is this intentional behavior? It seems like it could be meant to abstract logged error codes from the actual protocol used, maybe favoring HTTP because it's more widely recognized, but we wanted to reach out and check.

We also noticed that OK responses are logged as 0, which would be the correct status code for gRPC but is inconsistent with the HTTP ones and likely just an empty value.

@wscalf wscalf added the question Further information is requested label Oct 15, 2024
@shenqidebaozi
Copy link
Member

Yes, because HTTP and gRPC are isomorphic, they use the same identifier and are converted according to gRPC's conventions

@wscalf
Copy link
Author

wscalf commented Oct 17, 2024

Okay, and so it's intentional then that logging and metrics always report HTTP status codes?

@shenqidebaozi
Copy link
Member

shenqidebaozi commented Oct 18, 2024

Yes, the code for errors corresponds to the HTTP codes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants