-
Notifications
You must be signed in to change notification settings - Fork 4.6k
stats: add DelayedPickComplete and follow correct semantics #8465
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 2 commits
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 |
|---|---|---|
|
|
@@ -469,8 +469,9 @@ func (cs *clientStream) newAttemptLocked(isTransparent bool) (*csAttempt, error) | |
| func (a *csAttempt) getTransport() error { | ||
| cs := a.cs | ||
|
|
||
| var err error | ||
| a.transport, a.pickResult, err = cs.cc.getTransport(a.ctx, cs.callInfo.failFast, cs.callHdr.Method) | ||
| pickInfo := balancer.PickInfo{Ctx: a.ctx, FullMethodName: cs.callHdr.Method} | ||
| pick, err := cs.cc.pickerWrapper.pick(a.ctx, cs.callInfo.failFast, pickInfo) | ||
| a.transport, a.pickResult = pick.transport, pick.result | ||
| if err != nil { | ||
| if de, ok := err.(dropError); ok { | ||
| err = de.error | ||
|
|
@@ -481,6 +482,11 @@ func (a *csAttempt) getTransport() error { | |
| if a.trInfo != nil { | ||
| a.trInfo.firstLine.SetRemoteAddr(a.transport.RemoteAddr()) | ||
| } | ||
| if pick.blocked { | ||
| for _, sh := range a.statsHandlers { | ||
| sh.HandleRPC(a.ctx, &stats.DelayedPickComplete{}) | ||
|
Contributor
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. Should we also call
Member
Author
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. It's a type alias so the stats handler will get one event that matches both of the events. |
||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6649,13 +6649,13 @@ func (s) TestRPCBlockingOnPickerStatsCall(t *testing.T) { | |
| t.Fatalf("Unexpected error from UnaryCall: %v", err) | ||
| } | ||
|
|
||
| var pickerUpdatedCount uint | ||
| var delayedPickCompleteCount uint | ||
| for _, stat := range sh.s { | ||
| if _, ok := stat.(*stats.PickerUpdated); ok { | ||
| pickerUpdatedCount++ | ||
| if _, ok := stat.(*stats.DelayedPickComplete); ok { | ||
| delayedPickCompleteCount++ | ||
| } | ||
| } | ||
| if pickerUpdatedCount != 1 { | ||
| t.Fatalf("sh.pickerUpdated count: %v, want: %v", pickerUpdatedCount, 2) | ||
| if delayedPickCompleteCount != 1 { | ||
| t.Fatalf("sh.delayedPickComplete count: %v, want: %v", delayedPickCompleteCount, 2) | ||
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also specify that
DelayedPickCompleteshould be used instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Related: I think technically we're not supposed to put "Deprecated" on this until after
DelayedPickCompleteexists for a release. But since this package is experimental, I think we can skip that and call it deprecated immediately.