-
Notifications
You must be signed in to change notification settings - Fork 867
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
Change SpanStatusExtractor to use a builder that can set status description #6035
Change SpanStatusExtractor to use a builder that can set status description #6035
Conversation
I assume that we don't want to take breaking changes to the instrumenter interfaces, so we either need to break the new functionality into a new interface, or munge it into the existing one so that existing implementations (including lambdas) continue to work. I also did not touch the HttpSpanStatusExtractor or GrpcSpanStatusExtractor implementations in this pass. |
|
Good to know, that will make this much cleaner. |
Updated Just realized that |
if (error != null) { | ||
return StatusCode.ERROR; | ||
spanStatusBuilder.setStatus(StatusCode.ERROR, error.toString()); |
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'm unclear about this part of the spec:
When the status is set to
Error
by Instrumentation Libraries, theDescription
SHOULD be documented and predictable.
and whether an exception message is considered "predictable"
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 that statement makes sense for error conditions as interpreted by the instrumentation, e.g. a failing status code or the like. I can see where exceptions might be a bit murkier, but as long as the exception is being recorded as an event perhaps having it also be the description isn't as necessary (although I guess technically an exception event doesn't need to be the reason that the span status is "Error" either).
I can certainly unwind the rest of the changes here so the exception message is not the description. Would certainly make it easier to not have to deal with all of the exceptions that it broke. 😄
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 reverted setting the error message as the description by default, that's something we can revisit. This PR will instead only provide the SpanStatusExtractor
that is capable of setting that description.
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!
The exception message can contain pretty much anything (see #3039 for a really bad example), I too wouldn't call it "predictable". And we're already capturing it as the exception.message
attribute, adding the same string as status description would be duplicating the data a little bit.
8a84989
to
3609646
Compare
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!
LGTM 👍
if (status.isOk()) { | ||
return StatusCode.UNSET; | ||
spanStatusBuilder.setStatus(StatusCode.UNSET); | ||
} else { | ||
spanStatusBuilder.setStatus(StatusCode.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.
Nit: could be
if (!status.isOk()) {
spanStatusBuilder.setStatus(StatusCode.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.
thx!
Hey @HaloFour |
thx @HaloFour! |
…iption (open-telemetry#6035) * Change SpanStatusExtractor to use a builder that can set status descripion * Refactor SpanStatusExtractor to only support builder approach to setting status * Revert setting the exception as the status description * PR feedback * Re-fix graghql instrumentation span extractor * Spotless
Currently the
SpanStatusExtractor
can only extract aStatusCode
from the response and any error and never sets an appropriate description for the status of the span. This change adds a method to theSpanStatusExtractor
to use a helper interfaceSpanStatusBuilder
which delegates thesetStatus
methods to the underlyingSpan
so that the extractor may set the status code and description.