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

Report context cancelation as non-error #1

Open
wants to merge 3 commits into
base: fix-cancellation-race
Choose a base branch
from

Conversation

bboreham
Copy link

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:
image

Copied from opentracing-contrib#13

Someone else canceled this operation; we should not flag it as an error.

Signed-off-by: Bryan Boreham <[email protected]>
Copy link
Owner

@charleskorn charleskorn left a 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) {
Copy link
Owner

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().

Copy link
Author

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

Copy link
Owner

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?

@bboreham
Copy link
Author

For consistency, should we also change the events added to the span when a cancellation "error" is received?

Nice, but not important to me since nobody is putting a big red mark on the screen based on events.

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

Successfully merging this pull request may close these issues.

2 participants