-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Synchronize GitHub Source Code Mappings to Java Build Tool Model #546
Comments
Assigning to @getsentry/support for routing ⏲️ |
Routing to @getsentry/product-owners-settings-integrations for triage ⏲️ |
Hmm, will transfer to |
Hello @gilday we already have https://github.com/getsentry/sentry-android-gradle-plugin which allows you to upload source code. You can find docs here. Does that do what you want? |
I tried the plugin to see if it has the same behavior as that described by the source code mappings (i.e. link to source in GitHub), but the plugin does not work in my Gradle build. It fails with the error:
|
@romtsn do you know how to fix this? |
@gilday what Gradle version are you on? Also, do you know where does the |
I believe |
I've moved this to the SAGP repo where it should belong I believe. We'll have to investigate quarkus and see what it does (I've got a feeling that something they are doing is off, but maybe it's also us). |
Hi @gilday, Could you try to add the following to your
This should fix the dependency issue you are facing during the build. Please let us know if that helped. |
Not sure how this works exactly in the Sentry backend but we could try to make it smarter by recognizing popular build tools (Gradle, Maven) and auto mapping modules after scanning the repo. |
I too build SaaS developer tools, and having been down this road before, you may also find that Gradle project directory structures don't always conform to conventions that you can depend on from the outside looking in . The most reliable way to find the sources is to be in the Gradle build i.e. a plugin. JetBrains project model syncing is an example: the IDE needs to know is where the sources are, and it finds them by ways of a Gradle plugin. |
Ah thanks for the info. Good thing we already have a gradle and maven plugin, maybe they just need to be told the repo URL and offer some task that can set up mappings. |
* Disable sourceContext option to make build work. When setting this option to true, `authToken`, `org`, and `project` settings also need to be set. Documentation for setting them exists in the source context documentation. * Add section for running sentry task after code gen. Fix: getsentry/sentry-android-gradle-plugin#546 * some minor changes; re-enable source context in sample * Apply suggestions from code review Co-authored-by: Shana Matthews <[email protected]> * lint fix --------- Co-authored-by: Alexander Dinauer <[email protected]> Co-authored-by: Alexander Dinauer <[email protected]> Co-authored-by: Shana Matthews <[email protected]>
hi there 👋 I believe this issue should not be closed: it started with
but was closed with a commit mentioning documentation about setting dependency with code generation tasks. To circle back to the original request from @gilday, I'd like to second to
this is very on point 🎯 . I guess it's unlike that a team of multimodule Android project would invest into maintaining dozens of Code Mappings manually; therefore they lose plenty of great features you prepared (Stack Trace Links, Source Contexts etc.). Would you consider:
|
Sorry this was closed via the PR that added docs for a fix mentioned in this issue. Reopening. |
@wzieba afaict there's currently no API to configure code mappings. So achieving this seems a little more comlex than assumed. |
Thank you @adinauer for opening this again!
It's unfortunate :(. It'd be really great if there was one - ideally, mapping would be associated with the specific build via some kind of id (the same as Source Context or Proguard mappings are) as mapping can change from build to build. I hope this feature will be prioritized some day. |
Yeah we'll likely have to make this more generic and rework integrations as well. It's now back in our backlog but I can't say when we'll get to it. |
@wzieba you could take a look at the Sentry UI in browser dev tools and inspect API requests performed when adding code mappings, then replicate this in a script. |
Good idea @adinauer ! I've come up with something like this: custom tasktasks.register("createSentryMappings") {
doLast {
fun makeRequest(dryRun: Boolean, sourceRoot: String, stackRoot: String) {
println("About to send mapping\nsourceRoot: $sourceRoot\nstackRoot: $stackRoot\n---")
if (dryRun) return
val body = HttpRequest.BodyPublishers.ofString(
"""
{
"defaultBranch": "main",
"integrationId": "<id>",
"projectId": "<id>",
"repositoryId": "<id>",
"sourceRoot": "$sourceRoot",
"stackRoot": "$stackRoot"
}
""".trimIndent()
)
val request = HttpRequest
.newBuilder(URI("https://us.sentry.io/api/0/organizations/<org>/code-mappings/"))
.setHeader(
"Authorization",
"Bearer <token>"
)
.setHeader("Content-Type", "application/json")
.POST(body)
.build()
val response =
HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString())
logger.info(response.body())
}
rootProject.allprojects
.filter {
it.name !in listOf(
rootProject.name,
<projects_to_exclude>
)
}
.forEach {
makeRequest(
false,
sourceRoot = "modules/${it.project.parent!!.name}/${it.project.name}/src/main/java/au/com/shiftyjelly/pocketcasts/${it.project.name}",
stackRoot = "au/com/shiftyjelly/pocketcasts/${it.project.name}",
)
}
}
}
It's tailored for my use case with hard-coded source and stack roots, but I guess it can be a starting point for someone else looking for a way to automate sending mappings. |
Thanks @wzieba that's great 🚀 |
Problem Statement
I would like Sentry tooling to synchronize the source code mappings in my Sentry GitHub integration with my Java project structure.
Consider a multi-project Gradle project with subprojects
foo
,bar
, andbaz
. In this case, I would like an automated way to create source code mappings for directoriesfoo/src/main/java
,bar/src/main/java
, andbaz/src/main/java
.Solution Brainstorm
Java build tool (e.g. Maven and Gradle) are aware of projects' directory structures and the difference between production and test code. A Sentry Maven / Gradle plugin could query the project's structure and synchronize the GitHub source code mappings.
Product Area
Issues
The text was updated successfully, but these errors were encountered: