-
Notifications
You must be signed in to change notification settings - Fork 0
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
Report context cancelation as non-error #1
base: fix-cancellation-race
Are you sure you want to change the base?
Report context cancelation as non-error #1
Conversation
Someone else canceled this operation; we should not flag it as an error. Signed-off-by: Bryan Boreham <[email protected]>
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 this.
For consistency, should we also change the events added to the span when a cancellation "error" is received?
Currently, the code here, here and here will log all Golang error
values with event=error
, even if they represent a cancellation. Perhaps we should log them with event=cancelled
instead?
@@ -57,6 +60,9 @@ func SetSpanTags(span opentracing.Span, err error, client bool) { | |||
code := codes.Unknown | |||
if s, ok := status.FromError(err); ok { | |||
code = s.Code() | |||
} else if errors.Is(err, context.Canceled) { |
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.
We also need to check for code == codes.Canceled
here - the gRPC client libraries translate client-side context cancellations into gRPC errors with code Canceled
using either FromContextError
or toRPCErr
depending on when the error is observed by the client.
TestStreamingContextCancellationOpenTracing
doesn't cover this case because it doesn't test cancelling the context while a client is in a Recv()
or Send()
call - it cancels the context while the stream is open, but not while the client is in Recv()
or Send()
.
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; I have modified the code to check codes.Canceled
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. Could you please add a test to cover this case as well?
Nice, but not important to me since nobody is putting a big red mark on the screen based on events. |
Someone else canceled this operation; we should not flag it as an error.
Example of a span flagged as an error when the operation was cancelled as un-needed:
Copied from opentracing-contrib#13