You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to dig into this more, so this ticket is mostly investigate, but the gist is that a formatted traceback might look something like this:
org.springframework.security.authentication.AuthenticationServiceException: Authentication failed
at com.foobar.core.security.processor.AuthenticationProcessorImpl.authenticate(AuthenticationProcessorImpl.java:88)
Where in Sentry, we end up with a somewhat-incorrect traceback:
Caused by: org.springframework.security.authentication.AuthenticationServiceException ("Authentication failed") ? at line -1
com.foobar.core.security.processor.AuthenticationProcessorImpl ? in authenticate at line 88
The big things here being:
Caused by should actually be part of the Exception interface
We're not recording a filename (though I'm not sure whats all available there)
There might be some additional things to clean up here as well.
Of note, I'm going to change how Java (and more importantly language-based) tracebacks look so they feel more natural to each individual platform.
I think (been a while) the main reason the "Caused by" is actually included is to clarify wrapped exceptions.
Imagine the following stacktrace in which a FileNotFoundException is caught and rethrown, wrapped in a RuntimeException:
java.lang.RuntimeException: Could not open configuration at "/location"
at com.foo.something.Else.openConfig
at com.foo.something.Doing.boot
...
Caused by: FileNotFoundException: file "/location"
at com.foo.fs.Loader.load
...
The second part is pretty crucial in determining the actual cause so we snuck it in there. Any ideas?
So filename is something like com.foo.TheClass (as close as you can get to a filename in Java) for the stacktrace frames itself, but it is set to the exception's message for the first record we manually insert to keep track of the "Caused by" message. That's also the "frame" with lineno set to -1.
If we were able to pass a message for a the stacktrace interface or multiple exception interfaces, we could remove this work-around without dropping pretty important information.
Exception in thread "main" java.lang.IllegalStateException: A book has a null property
at com.example.myproject.Author.getBookIds(Author.java:38)
at com.example.myproject.Bootstrap.main(Bootstrap.java:14)
Caused by: java.lang.NullPointerException
at com.example.myproject.Book.getId(Book.java:22)
at com.example.myproject.Author.getBookIds(Author.java:35)
... 1 more
This exception (IllegalStateException) is logged: logger.error("Could not get books", e).
What we end up with in the client is:
the message Could not get books
a Throwable of type IllegalStateException which contains the message A book has a null property, the stacktrace elements and the optional cause of the exception (i.e. the NullPointerException).
Each at com.example... is a stacktrace element which is added as a frame of Sentry's Stacktrace interface. The only information those elements contain are the name of the class, the name of the method and the line number. So no, not every frame needs a message; adding a message attribute to the Stacktrace interface would probably be the wrong way to go.
In the above scenario we're now adding the IllegalStateException as Sentry's Exception interface and the stacktrace elements of both exceptions to the Stacktrace interface, with an extra frame in between to get our "Caused by: java.lang.NullPointerException" back.
Ideally we'd be able to add both exceptions through the Exception interface.
One of the most useful things we would like to see is the plain/raw unprocessed full java stack trace in the sentry ui. That would allow us to paste it in any popular java ide and have full visibility and navigatability of everything that happened leading to the error. At the moment the stack trace show in the ui is so different from a standard java exceptions that it cannot be used in the manner I described above.
I can provide example code for getting the full stack trace with all nested exceptions as a string if required.
I'm not sure cause is the best word here for the internals. Thoughts?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/43#issuecomment-15200933.
Wrapping exceptions in Java is far more common, especially with frameworks like Spring that like to turn checked into unchecked exceptions. And yeah, cause... original might fit the bill a bit better.
My $0.02 here. The term cause is inline with the Java API, see Throwable#getCause(). It is also quite common in Java to have multiple levels of nested exceptions. For example:
org.apache.myfaces.view.facelets.el.ContextAwareELException ("javax.el.ELException: Error reading 'var' on type foo.Object
org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression in getValue at line 104 (application)
javax.faces.component._DeltaStateHelper in eval at line 266 (application)
javax.faces.component.UIComponentBase in isRendered at line 1187 (application)
...
Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException ("Unknown column 'object.var' in 'field list'; SQL [n/a];")
org.springframework.orm.hibernate3.SessionFactoryUtils in convertHibernateAccessException at line 635 (application)
org.springframework.orm.jpa.vendor.HibernateJpaDialect in translateExceptionIfPossible at line 105 (application)
...
Caused by: org.hibernate.exception.SQLGrammarException: Unknown column 'object.var' in 'field list'
org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:82)
org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
...
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException ("Unknown column 'object.var' in 'field list'")
sun.reflect.NativeConstructorAccessorImpl in newInstance0 at line -2 (application)
sun.reflect.NativeConstructorAccessorImpl in newInstance at line 57 (application)
sun.reflect.DelegatingConstructorAccessorImpl in newInstance at line 45 (application)
...
I would imagine Java developers like to see all wrapped exceptions, even though some may be redundant. In this case, would the JSON request object support nested objects as well? For example:
As a side note, because of nested exceptions, sometimes stack trace messages from Java can be super long. The example above actually had something like 500 lines in its entirety. To make the message easier to read, it would be awesome if Sentry’s UI allows additional frames to be toggleable.
One of the most useful things we would like to see is the plain/raw unprocessed full java stack trace in the sentry ui. That would allow us to paste it in any popular java ide and have full visibility and navigatability of everything that happened leading to the error. At the moment the stack trace show in the ui is so different from a standard java exceptions that it cannot be used in the manner I described above.
I can provide example code for getting the full stack trace with all nested exceptions as a string if required.
It almost feels like we might need to rethink stacktrace + exception separation here.
The gist of it as I see it is like this:
At the high level it's still a single exception
It contains many exceptions
Each exception contains an (optional) stacktrace
We could provide a new interface which simply represents this kind of construct, and start moving things in that direction to better handle these cases.
I see, so correct me if I'm misinterpreting, but those events, if there aren't exception should be considered as simple messages, right?
If that's the case, it would be sensible to have the possibility of having a message with stacktrace as well as an exception with stacktrace, but it would be rarely (or even completely impossible) to have only a stacktrace by itself.
And if I'm right the best approach would be improving the interfaces Message and Exception by adding an additional (but optional) arg stacktrace.
This wouldn't solve the main issue (which is that an exception in java may contain an other exception) but would help to make things clearer (and it would be easy from there to simply say that an exception may contain an other exception (that will possibly contain another stacktrace, and possibly an other exception, etc.)
I dont know mucha bout Java, but if someone has an answer to what kind of value that is in the exception, I'd love to take a stab at getting that solved as well.
@ColinHebert to be fair this still all might be a problem with the way we use Cause in tracebacks, so could still be solved by just correcting how chained exceptions work
I think the exception message (value) should still be present here, and the type of the first exception should be clear.
An other things is that it would be interesting to show/hide frames for each exception (and causes) independently.
Just to be clear, in the mockup I just sent, there are two exceptions (with their respective stacktraces):
The first one is a RequestError (with the message "message of the first exception"), and has a stacktrace with only one frame (plus 4 hidden frame).
The first exception was caused by the second one.
The second exception is a RequestError too (technical limitations on my side, I should have changed the name of the error) with the message "message of the second exception".
The second exception has a stacktrace with 4 frames (plus 12 hidden frames).
@ColinHebert@roam I will play with the visuals some more, but I'll make sure we keep the message in. We might be able to simplify the traditional (unchained) exceptions if we make them appear like this as well.
Activity
roam commentedon Mar 20, 2013
I think (been a while) the main reason the "Caused by" is actually included is to clarify wrapped exceptions.
Imagine the following stacktrace in which a FileNotFoundException is caught and rethrown, wrapped in a RuntimeException:
The second part is pretty crucial in determining the actual cause so we snuck it in there. Any ideas?
dcramer commentedon Mar 20, 2013
@roam is that specifically the culprit (does it exist somewhere else in the stacktrace)?
roam commentedon Mar 20, 2013
It's not a part of a standard Java stacktrace but inserted by the client code.
So
filenameis something likecom.foo.TheClass(as close as you can get to a filename in Java) for the stacktrace frames itself, but it is set to the exception's message for the first record we manually insert to keep track of the "Caused by" message. That's also the "frame" withlinenoset to -1.If we were able to pass a
messagefor a the stacktrace interface or multiple exception interfaces, we could remove this work-around without dropping pretty important information.dcramer commentedon Mar 20, 2013
@roam is it true that all frames in Java can have a message attached to them?
dcramer commentedon Mar 20, 2013
Actually a followup here, would both stacktraces be the same and just a different exception message/value?
roam commentedon Mar 20, 2013
Here's a typical stacktrace:
This exception (IllegalStateException) is logged:
logger.error("Could not get books", e).What we end up with in the client is:
Could not get booksThrowableof typeIllegalStateExceptionwhich contains the messageA book has a null property, the stacktrace elements and the optional cause of the exception (i.e. the NullPointerException).Each
at com.example...is a stacktrace element which is added as a frame of Sentry's Stacktrace interface. The only information those elements contain are the name of the class, the name of the method and the line number. So no, not every frame needs a message; adding amessageattribute to the Stacktrace interface would probably be the wrong way to go.In the above scenario we're now adding the
IllegalStateExceptionas Sentry's Exception interface and the stacktrace elements of both exceptions to the Stacktrace interface, with an extra frame in between to get our "Caused by: java.lang.NullPointerException" back.Ideally we'd be able to add both exceptions through the Exception interface.
dcramer commentedon Mar 20, 2013
We could extend Exception to allow for a cause/culprit exception with the intention to handle composites.
Python has some odd things like this sometimes too, where its like:
An exception FOO happened, I caught it, and I reraised it as BAR.
What if the exception interface became:
I'm not sure cause is the best word here for the internals. Thoughts?
oliverhenlich commentedon Mar 20, 2013
Hi David.
Thanks again for following this up.
One of the most useful things we would like to see is the plain/raw unprocessed full java stack trace in the sentry ui. That would allow us to paste it in any popular java ide and have full visibility and navigatability of everything that happened leading to the error. At the moment the stack trace show in the ui is so different from a standard java exceptions that it cannot be used in the manner I described above.
I can provide example code for getting the full stack trace with all nested exceptions as a string if required.
Cheers
Oliver
On 21/03/2013, at 9:21, "David Cramer" <[email protected]mailto:[email protected]> wrote:
We could extend Exception to allow for a cause/culprit exception with the intention to handle composites.
Python has some odd things like this sometimes too, where its like:
An exception FOO happened, I caught it, and I reraised it as BAR.
What if the exception interface became:
{
"type": ...,
"value": ...,
"cause": {
"type": ...,
"value": ...
}
}
I'm not sure cause is the best word here for the internals. Thoughts?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/43#issuecomment-15200933.
roam commentedon Mar 20, 2013
@dcramer That looks perfect!
Wrapping exceptions in Java is far more common, especially with frameworks like Spring that like to turn checked into unchecked exceptions. And yeah,
cause...originalmight fit the bill a bit better.vvasabi commentedon Mar 20, 2013
My $0.02 here. The term
causeis inline with the Java API, see Throwable#getCause(). It is also quite common in Java to have multiple levels of nested exceptions. For example:I would imagine Java developers like to see all wrapped exceptions, even though some may be redundant. In this case, would the JSON request object support nested objects as well? For example:
As a side note, because of nested exceptions, sometimes stack trace messages from Java can be super long. The example above actually had something like 500 lines in its entirety. To make the message easier to read, it would be awesome if Sentry’s UI allows additional frames to be toggleable.
oliverhenlich commentedon Mar 20, 2013
Hi Guys.
Thanks David for creating this ticket for me.
One of the most useful things we would like to see is the plain/raw unprocessed full java stack trace in the sentry ui. That would allow us to paste it in any popular java ide and have full visibility and navigatability of everything that happened leading to the error. At the moment the stack trace show in the ui is so different from a standard java exceptions that it cannot be used in the manner I described above.
I can provide example code for getting the full stack trace with all nested exceptions as a string if required.
Cheers
Oliver
dcramer commentedon Mar 20, 2013
It almost feels like we might need to rethink stacktrace + exception separation here.
The gist of it as I see it is like this:
We could provide a new interface which simply represents this kind of construct, and start moving things in that direction to better handle these cases.
ColinHebert commentedon Apr 3, 2013
If I may ask, why is there a separation between stacktrace and exception in the first place?
I understand that you could have an exception without stacktrace under some circumstances, but a stacktrace without an exception seems weird to me.
dcramer commentedon Apr 3, 2013
In Python, for example we can send any kind of event with a stacktrace. That's where the original split came from
On Wed, Apr 3, 2013 at 8:43 AM, Colin Hebert [email protected]
wrote:
ColinHebert commentedon Apr 3, 2013
I see, so correct me if I'm misinterpreting, but those events, if there aren't exception should be considered as simple messages, right?
If that's the case, it would be sensible to have the possibility of having a message with stacktrace as well as an exception with stacktrace, but it would be rarely (or even completely impossible) to have only a stacktrace by itself.
And if I'm right the best approach would be improving the interfaces
MessageandExceptionby adding an additional (but optional) argstacktrace.This wouldn't solve the main issue (which is that an exception in java may contain an other exception) but would help to make things clearer (and it would be easy from there to simply say that an exception may contain an other exception (that will possibly contain another stacktrace, and possibly an other exception, etc.)
1 remaining item
dcramer commentedon Apr 3, 2013
@ColinHebert that's how it already works.
I think what we'll likely end up doing is expanding on the Exception event that supports additional information.
One thing of note, is that in the newer versions of Python they support chained exceptions, they have two types of chaining:
I'm not sure if this is available in Java, but it's something to consider as we try to solve this on the server side.
dcramer commentedon Apr 3, 2013
I've updated getsentry/sentry#842 with a proposed solution on the server. Object now or I'll implement this week and we can add it to the Java client
dcramer commentedon Apr 4, 2013
Adding this in here, it might be a different problem, but I'm not sure:
https://gist.github.com/jdwyah/5313560
I dont know mucha bout Java, but if someone has an answer to what kind of value that is in the exception, I'd love to take a stab at getting that solved as well.
ColinHebert commentedon Apr 4, 2013
I replied there, but I don't really know about the context, what is happening exactly?
dcramer commentedon Apr 4, 2013
@ColinHebert to be fair this still all might be a problem with the way we use Cause in tracebacks, so could still be solved by just correcting how chained exceptions work
dcramer commentedon Apr 5, 2013
We don't currently show the
moduleattribute with exception types (which maybe we need to change) but what do you think about this:https://dl.dropbox.com/s/u5ovrq7ko8w7f9k/Screen%20Shot%202013-04-04%20at%209.48.49%20PM.png
(this is just a mock up, not a real example)
ColinHebert commentedon Apr 5, 2013
I think the exception message (value) should still be present here, and the type of the first exception should be clear.
An other things is that it would be interesting to show/hide frames for each exception (and causes) independently.
Behold my designer talents (made with preview.app):
http://i.imgur.com/TaqHzmw.png
ColinHebert commentedon Apr 5, 2013
Just to be clear, in the mockup I just sent, there are two exceptions (with their respective stacktraces):
The first one is a RequestError (with the message "message of the first exception"), and has a stacktrace with only one frame (plus 4 hidden frame).
The first exception was caused by the second one.
The second exception is a RequestError too (technical limitations on my side, I should have changed the name of the error) with the message "message of the second exception".
The second exception has a stacktrace with 4 frames (plus 12 hidden frames).
roam commentedon Apr 5, 2013
The mockup by @ColinHebert is indeed what Java developers are looking for (or at least I am).
dcramer commentedon Apr 5, 2013
@ColinHebert @roam I will play with the visuals some more, but I'll make sure we keep the message in. We might be able to simplify the traditional (unchained) exceptions if we make them appear like this as well.
dcramer commentedon Apr 8, 2013
I'll be landing this soon with protocol version 4 of Sentry.
Here's the current implementation:
https://dl.dropbox.com/s/f6h74wfeaqwdwxh/Screen%20Shot%202013-04-07%20at%2011.19.26%20PM.png
ColinHebert commentedon Apr 8, 2013
That's nice. What about the "show hidden frames" checkbox for each stacktrace?
Also, are there other changes coming with the version 4 of the protocol?
ColinHebert commentedon May 14, 2013
Close as getsentry/sentry#842 is now handled (use raven-4.x)
ref: Reuse logger instance if possible (#43)