Skip to content

Report context cancelation as non-error - #1

Open
bboreham wants to merge 3 commits into
charleskorn:fix-cancellation-racefrom
bboreham:dont-log-canceled-ck
Open

Report context cancelation as non-error#1
bboreham wants to merge 3 commits into
charleskorn:fix-cancellation-racefrom
bboreham:dont-log-canceled-ck

Conversation

@bboreham

Copy link
Copy Markdown

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 <bjboreham@gmail.com>

@charleskorn charleskorn left a comment

Copy link
Copy Markdown
Owner

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?

Comment thread errors.go
code := codes.Unknown
if s, ok := status.FromError(err); ok {
code = s.Code()
} else if errors.Is(err, context.Canceled) {

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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