-
Notifications
You must be signed in to change notification settings - Fork 4.5k
stats/opentelemetry: add trace event for name resolution delay #8074
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
stats/opentelemetry: add trace event for name resolution delay #8074
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8074 +/- ##
==========================================
- Coverage 82.25% 82.03% -0.23%
==========================================
Files 393 410 +17
Lines 39143 40248 +1105
==========================================
+ Hits 32197 33016 +819
- Misses 5616 5867 +251
- Partials 1330 1365 +35
🚀 New features to boost your workflow:
|
internal/internal.go
Outdated
// When set, the function should be called before the stream enters | ||
// the blocking state. |
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.
// When set, the function should be called before the stream enters | |
// the blocking state. | |
// When set, the function will be called before the stream enters | |
// the blocking state. |
Nit: "Should" implies uncertainty.
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.
Done
clientconn.go
Outdated
if internal.NewStreamWaitingForResolver != nil { | ||
internal.NewStreamWaitingForResolver() | ||
} |
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.
if internal.NewStreamWaitingForResolver != nil { | |
internal.NewStreamWaitingForResolver() | |
} | |
internal.NewStreamWaitingForResolver() |
(Combine with suggestion below)
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.
Done
internal/internal.go
Outdated
// used in tests to synchronize resolver updates and avoid race conditions. | ||
// When set, the function should be called before the stream enters | ||
// the blocking state. | ||
NewStreamWaitingForResolver func() |
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.
NewStreamWaitingForResolver func() | |
NewStreamWaitingForResolver = func() {} |
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.
Done
test/clientconn_test.go
Outdated
// Add grpcsync.Event to coordinate timing | ||
resolutionWait := grpcsync.NewEvent() | ||
prevHook := internal.NewStreamWaitingForResolver | ||
internal.NewStreamWaitingForResolver = func() { _ = resolutionWait.Fire() } |
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.
internal.NewStreamWaitingForResolver = func() { _ = resolutionWait.Fire() } | |
internal.NewStreamWaitingForResolver = func() { resolutionWait.Fire() } |
I think this won't fail vet
?
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.
Yeah, it won’t fail vet. I’ve made the changes.
stats/opentelemetry/e2e_test.go
Outdated
if err != nil { | ||
return err | ||
} | ||
if err := stream.Send(&testpb.StreamingOutputCallRequest{}); err != nil && err != io.EOF { |
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.
Why the io.EOF
check here? The server should never exit until the client does CloseSend
.
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.
Thanks for the suggestion; I have removed it.
stats/opentelemetry/e2e_test.go
Outdated
time.AfterFunc(100*time.Millisecond, func() { | ||
rb.UpdateState(resolver.State{Addresses: []resolver.Address{{Addr: ss.Address}}}) | ||
}) |
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.
This will have the same race as in the other tests. It should inject something to hook the resolver blocking, too.
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.
I’ve updated the test to set this to a grpcsync.Event.Fire
stats/opentelemetry/e2e_test.go
Outdated
if !match { | ||
t.Errorf("Expected span not found: %q (kind: %s)", want.name, want.spanKind) | ||
} | ||
|
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.
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.
Done
stats/opentelemetry/e2e_test.go
Outdated
headerAttempts := len(md["grpc-previous-rpc-attempts"]) | ||
if headerAttempts >= 1 { | ||
return &testpb.SimpleResponse{}, nil | ||
} | ||
return nil, status.Error(codes.Unavailable, fmt.Sprintf("retry (%d)", headerAttempts)) |
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.
I think you want something more like this
headerAttempts := len(md["grpc-previous-rpc-attempts"]) | |
if headerAttempts >= 1 { | |
return &testpb.SimpleResponse{}, nil | |
} | |
return nil, status.Error(codes.Unavailable, fmt.Sprintf("retry (%d)", headerAttempts)) | |
headerAttempts := 0 | |
if h := md["grpc-previous-rpc-attempts"]; len(h) > 0 { | |
headerAttempts = h[0] | |
} | |
if headerAttempts < 2 { | |
return nil, status.Errorf(codes.Unavailable, "retry (%d)", headerAttempts) | |
} | |
return &testpb.SimpleResponse{}, nil |
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.
Done
stats/opentelemetry/e2e_test.go
Outdated
return &stubserver.StubServer{ | ||
FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error { | ||
md, _ := metadata.FromIncomingContext(stream.Context()) | ||
headerAttempts := len(md["grpc-previous-rpc-attempts"]) |
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.
Similar to above.
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.
Done
test/clientconn_test.go
Outdated
} | ||
} | ||
|
||
func waitForReady(cc *grpc.ClientConn) error { |
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.
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.
Done
stats/opentelemetry/e2e_test.go
Outdated
if val, err := strconv.Atoi(h[0]); err == nil { | ||
headerAttempts = val | ||
} |
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.
This is test code, so you don't need to even look at the error (and zero is returned on a parse error anyway).
if val, err := strconv.Atoi(h[0]); err == nil { | |
headerAttempts = val | |
} | |
headerAttempts, _ = strconv.Atoi(h[0]) |
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.
Done
stats/opentelemetry/e2e_test.go
Outdated
return status.Error(codes.Unavailable, fmt.Sprintf("retry (%d)", headerAttempts)) | ||
headerAttempts := 0 | ||
if h := md["grpc-previous-rpc-attempts"]; len(h) > 0 { | ||
if val, err := strconv.Atoi(h[0]); err == nil { |
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.
As above
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.
Done
stats/opentelemetry: add trace event for name resolution delay.
RELEASE NOTES: