-
Notifications
You must be signed in to change notification settings - Fork 893
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
RecordException and Span.Status #1008
Comments
As recordException can also be used for handled exceptions, I don't think it should. Also, then you would need to set the status back to UNSET if you disagreed with the default behavior, which is something we want to avoid. I think setting the status should always be explicit. CC @tedsuo |
That said, I think we can recommend that if you record an escaped exception (also setting exception.escaped=true) one should probably (manually) set the status to ERROR. |
I think that if some instrumentation is explicitly calling the |
I don't think so. A handled exception might be interesting because it may make the operation slower than it needs to be but is an unreachable cache, for example, an error for the parent operation? I think we should not hardcode this decision in recordException. |
I don't think so. We also do not set exception.escaped to true by default, even though it will be the most common use case for auto instrumentation (we don't even provide an overload to set it conveniently, see #784). |
I think we're making the API hard to use correctly for the most common use-case for an end-user, which is simply to mark something as an error, with the associated exception. We should make the most common use-case easy for the end user, not complicated and hard to figure out. |
from the issue triage mtg today with TC, allowing changes related to this issue for GA if editorial changes only |
I think this is very important distinction and it seems that different people have very different opinions about that. #966 says, and I agree, that default status should be
I don't think that |
When we had 16 statuses, it definitely didn't make sense to set one of those statuses when recording an exception. We have a much simpler set of statuses now, so it becomes (IMO) much more intuitive to do it in one step, rather than 2. |
I think you will need to set an error status maybe 75% of the time, but in the other case, you will have a wrong status code of ERROR which is IMHO worse than the missing information represented by UNSET. And nothing prevents Java from providing a helper like public static void doTraced(SpanBuilder spanBuilder, Consumer<Span> body) {
final Span span = spanBuilder.start();
try {
body(span);
} catch (Throwable t) {
span.recordException(t, Attributes.of(SemanticAttributes.EXCEPTION_ESCAPED, true));
span.setStatus(Status.of("Exit by exception", StatusCode.ERROR));
throw t;
} finally {
span.end();
}
} I think this is a very common pattern, but having recordException set an error implicitly by default is certainly not what we want. I suggest providing a convenience method like the above or some recordFatalException, recordUnhandledException, etc., that set escaped=true and also a status of ERROR. That would make sense, but should be a separate convenience method (preferably not even in the core API). We should avoid too much feature creep in recordException. It seems to attract that 😃 |
It remained unclear to me after #966 if
Span.RecordException
should or should not also result in setting Span.Status to ERROR? My question is not "should API method do both", but more "should Instrumentation Library set status to ERROR whenever they record exception or not?"The text was updated successfully, but these errors were encountered: