-
Notifications
You must be signed in to change notification settings - Fork 163
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
feat: add grpc tag to indicate request had been throttled #1531
Conversation
40982e3
to
a54d62c
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1531 +/- ##
==========================================
+ Coverage 86.06% 86.06% +0.01%
==========================================
Files 85 85
Lines 8038 8039 +1
==========================================
+ Hits 6917 6918 +1
Misses 790 790
Partials 331 331 ☔ View full report in Codecov by Sentry. |
Can you ellaborate on this in the PR description? Who is the caller that will take action based on this tag? And what will that action be? FWIW, today, any context tags are logged automatically. Also once you apply a tag to a context, any parent or children contexts also get that tag. |
Done. |
This won't work if a person uses OpenFGA as a library and doesn't wrap it within a server. The grpc tags middleware must be running. I.e. this doesn't print anything: ctx := context.Background()
grpc_ctxtags.Extract(ctx).Set("key-a", true)
tags := grpc_ctxtags.Extract(ctx)
for k, v := range tags.Values() {
fmt.Println("Tag: %s, Value: %s", k, v)
} |
Description
We need to convey request has been throttled so that caller can distinguish whether timeout is due to throttling.
Note that we cannot return timeout error in the distpatch throttler itself because the caller will not wait for error response in case of context timeout.
The caller (for example), the user of the OpenFGA library, may choose to use this grpcTag ("Throttled") to modify the error message returned due to request timeout. They may also update the returned header to indicate the request has been throttled.
References
Continuation of #1440
Review Checklist
main