-
Notifications
You must be signed in to change notification settings - Fork 758
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
.net definition for exception.stacktrace should be chosen and defined #1569
Comments
I think I've found the origin of the problem: It has a message field listed, which is where the list of supported stacks is from. I suspect that exception.ToString() is actually listed as it provides the complete requirement for message:
Which Exception.ToString() would achieve in one call. I think that OpenTelemetry should just be logging the StackTrace, and then recordexception for the innerexception (if there is one). |
You are (understandably) expecting the wrong thing: |
Unless I'm misreading the definition is: A stacktrace as a string in the natural representation for the language runtime. The representation is to be determined and documented by each language SIG. That, to me, says it should be the stack trace. The type and message are already captured. I'd expect innerexceptions to also be captured as separate exceptions, rather than nested into the stack trace (from ToString) What you're suggesting as the most detailed exception details sounds more like opentrace. |
The current definition is maybe ambiguous. But the examples, corresponding implementations in other languages, and the linked discussion make clear that indeed you want the fuller representation, not just the stacktrace as in "list of frames". To view it from another perspective: Who says that a stacktrace is just a list of frames? E.g. in Java printStackTrace prints not only the frames but all inner exceptions, etc. So I think it is fair to say, that a stacktrace is more than a list of frames in this definition in the spec. |
I guess it depends on context. My expectation is that open telemetry was about adding structure to things, using ex.ToString() feels like an information duplication (eg with exception.type and exception.message) But also a loss of information for inner exceptions, as they'll end up in the Stacktrace and not in their own exception record, and so loosing some of the ability to locate inner exceptions by type or message I'll have to read the discussion, but my expectation was to be more structured with data. I assumed the Java printstacktrace is in its format for console logging (but I admit to not being that familiar with other languages) |
Regarding that, there were discussions before the linked one and it was agreed that a structured representation would be desirable but would require far more spec-work, and the unstructured "stacktrace" makes most people already happy. |
Linking a related discussion from a non-OTel repo: |
Feature Request
Is your feature request related to a problem?
I was looking over the exception handling for otel.dotnet here:
https://github.com/open-telemetry/opentelemetry-dotnet/blob/master/src/OpenTelemetry.Api/Trace/ActivityExtensions.cs#L72
I was wondering why the stack trace is ex.ToString() rather than ex.StackTrace?
I see here: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/exceptions.md#stacktrace-representation
there's a suggestion this is something that google cloud does, but it's up-to-the SIG to define. Other listed implementation suggest it's just a stack.
However, ex.ToString() will duplicate lots of extra information that's already in the exception.type and exception.message, and it's possible it doesn't even have the stack trace if the ToString is overridden in some way.
Checking reference source, suggests that ex.ToString() will by default capture the classname (which is probably a close match to
exception.type) the message and the stack trace.
The main difference I can see is that ToString() also goes through any InnerException, I'd have expected that inner exception should be recorded as another exception, (so it may end up recursive)
Or is it handling the scenario where a custom exception has also overridden ToString() to provide more information?
From my own perspective we tend to encourage people to log ex.ToString(), but I've heard of cases where the ex.ToString() can be very long. So I'm not sure it's the right choice for an activity/trace.
Describe the solution you'd like:
Clarity on if stacktrace should be just the stack (as I'd expect) or the full ex.tostring()
Describe alternatives you've considered.
I could create a helper routine that achieves something similar, but I'd expect confusion with having a helper and an opentelemetry api doing similar, but different things.
The text was updated successfully, but these errors were encountered: