-
-
Notifications
You must be signed in to change notification settings - Fork 442
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
Java Source Context #633
Comments
Still not possible? |
Still not possible? |
Still not possible? |
So I tried doing this a few years ago and mainly ran into complications with the tooling and introspection. For source context to work we would like to ideally piggyback on the source bundle system we use for a few other platforms. For this to work we need to do the following things:
There are a handful of restrictions unfortunately. The biggest one is that the file name does not actually exist in the stack trace. This is not an unsolvable problem as we could derive made up file names based on the class path (replace There were also too many different build systems (gradle, maven etc.) to make this work and a lot of code uses published maven archives and it was unclear how we get access to those sources. So maybe a new approach could be found where we leverage the gradle plugin for Android as a first step and start creating source bundles there. For the build ID to give the bundle we could use a similar system as we already use for the proguard files. Then we have a starting point and can see if there is a way to expand it from there. |
The build system is aware of the full dependency tree for a given JAR artifact and a custom maven/gradle plugin should be able to dump the info into some resource. If the format is simple enough, I believe the community would have no problem providing implementations for less common build systems. Once you have that info, you can attach it to the event, or publish it as a release artifact (better). Creating a hack that would derive filenames from class paths is IMHO a bad idea, as JVM doesn't really care much about filenames, it cares about classpath/modulepath. The final classpath/modulepath can be also derived from build system and included in the artefact describing the dependencies. Once you know the installed dependencies and the final classpath, you can then fetch the dependencies and lookup the correct file using the classpath. Most artifacts can be found on public maven registry, but some will be privately published on company's internal package registry, which would make fetching the sourcecode a bit harder. |
I think it's fair to assume that if a company uses internal package registry, to get source context support they must publish there sources jars as well. |
We have released Java Source context for Android, Backends, Desktop, ... now. Below you can find some more details on how this works under the hood, limitations, etc. DocsKnown limitations
Minimum required versions
Follow Up Tasks
What it looks like in Sentry UIScreenshot![Screenshot 2023-03-29 at 10 39 36](https://user-images.githubusercontent.com/2542832/228498054-247a67cc-8a02-4888-9603-aa9084e66e6d.png)Implementation DetailsImplementation Details### During build timeIn Build System
|
We've just released Source Context support for Android. Please give it a try: https://github.com/getsentry/sentry-android-gradle-plugin/releases/tag/3.7.0 (which uses https://github.com/getsentry/sentry-java/releases/tag/6.19.0) Any feedback is welcome 🙏 We're still working on adding Source Context for Backend etc. - stay tuned. |
I'm not quite sure where to ask this, but I thought here was more appropriate than the sentry-android-gradle-plugin PR and because you specifically asked for feedback: Is there a path to source code uploading for Android with Or maybe this is more of a hosted Sentry question, where we're used to have source code available for non-processed files in e.g. Python and/or direct links to GitHub. It would be nice if we were able to have a similar experience in the issue interface to see source code directly in Sentry for context. |
The PR linked is rather about uploading proguard mappings, but not the source context. For source context we just hook into the As for self-hosted - yes you'd have to update to the latest version, as there were some necessary changes on the stacktrace processing. |
I see now, I spoke too soon. With |
I've added another sentence to clarify ProGuard isn't a requirement for using Source Context. |
We have now released Java Source Context support for Backend, Desktop, etc. via Gradle and Maven as well. Please take a look at #633 (comment) for more details. Docs are coming soon. |
Um is there a reason we can't specify the URL for self hosted in Gradle? EDIT: okay so docs don't bother to mention that the usual sentry.properties is still respected for this, instead suggesting you have to specify the org/project/auth token in build.gradle.kts |
@androidacy-user thanks for bringing this up, we'll improve docs. I've created #2854 to track. |
Edit by maintainers: We've put Java Source Context on our roadmap. More details and progress can be found in a comment further down (#633 (comment))
Summary
I would like to be able to see sources in stacktraces of java exceptions, the same way they're visible for javascript.
Motivation
This would improve my ability to see the problem in the context of my application.
Additional Context
Sentry java client, should be able to access
classpath
of the running application and build process should be able to provide versions of installed libraries and built artefacts. Combining these two informations, Sentry should be able to render source code of Java. This would allow you to render on at least some frames of the stacktrace (there will always be generated/proxy frames, that will have no "visible" source code available).By uploading correct artifact (with sources) to a release, I should be able fill in the main part - source code of my own application.
And it would be ideal, if fetching "public" maven jars with sources could be a native part of Sentry, since these libraries take up a massive amount of disk storage, and if they would duplicate on each release, this would be unfeasible. Having a shared cache between releases would be ideal.
Refs
The text was updated successfully, but these errors were encountered: