-
Notifications
You must be signed in to change notification settings - Fork 111
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
Fix: multiple calls to end of span #75
Changes from all commits
feb6157
a96f099
1a6376d
3d5561b
5042cae
6082a6d
dbe356e
1bcaee8
a5c5d01
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 |
---|---|---|
|
@@ -54,6 +54,16 @@ static ImmutableMap<String, AttributeValue> getExceptionAnnotations(SpannerExcep | |
"Status", AttributeValue.stringAttributeValue(e.getErrorCode().toString())); | ||
} | ||
|
||
static void setWithFailure(Span span, Throwable e) { | ||
if (e instanceof SpannerException) { | ||
span.setStatus( | ||
StatusConverter.fromGrpcStatus(((SpannerException) e).getErrorCode().getGrpcStatus()) | ||
.withDescription(e.getMessage())); | ||
} else { | ||
span.setStatus(Status.INTERNAL.withDescription(e.getMessage())); | ||
} | ||
} | ||
|
||
static void endSpanWithFailure(Span span, Throwable e) { | ||
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. is endSpanWithFailure used anywhere now? If not then please remove it. 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. This has been used in a few places (ex: singleUse) where span does not end except when there is a failure. See: https://github.com/googleapis/google-cloud-java/pull/2677/files#r157323309 for original reason. |
||
if (e instanceof SpannerException) { | ||
endSpanWithFailure(span, (SpannerException) e); | ||
|
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.
tracer.getCurrentSpan()
is called outside of scope, which meansendSpanWithFailure
will execute on either READ_WRITE_TRANSACTION or READ_ONLY_TRANSACTION span instead of WAIT_FOR_SESSION span.