-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Add support for Go source bundles #1979
Comments
@cleptric I spent some time investigating this issue yesterday and today. It appears that the Go compiler includes debug symbol information in the binaries it generates. However, the debug symbol information does not include a Debug ID, which the CLI requires in order to be able to generate and upload a source bundle. I tried commenting out the CLI code that enforces this limitation and uploading the source bundle anyways – the CLI generated and uploaded the source bundle properly, but source context did not work when I sent an example event because the lack of a debug ID means that Sentry cannot find the source bundle corresponding to the error event. I discussed this situation on a call with @loewenheim and @Swatinem today to see if there is some way we would be able to work around this limitation. Our consensus was that – even if we were to disable the limitation in the CLI requiring debug files to have a debug ID – the only way that Sentry would be able to correlate events back to the source bundle would be if there is a unique ID associated with each build and source bundle, which the Go SDK would send with each event, and which Sentry would be able to use to associate the event with the correct source bundle. We tried using several different tools to see whether the binary had a debug ID or some other unique build ID, but we unfortunately could not find anything. @cleptric, are you aware of whether the Go compiler is supposed to inject a debug ID or whether there is a way to enable such functionality? Perhaps we missed something. But if not, @loewenheim, @Swatinem, and I agree that the only way it would be possible for us to support Go bundles would be with some change in the Go SDK that allows us to somehow associate error events back to the correct source bundle. |
@szokeasaurusrex is it always needed to match on a debug ID? If there is one source bundle that has the same release/dist, it can just use that to match right? |
@jerbob92, this functionality is indeed supported for JavaScript sourcemaps, but I am unsure whether we support such functionality for languages that get compiled into binaries (i.e. where we use debug files instead of sourcemaps). In any case, we have moved away from the release/dist matching in JavaScript and now only maintain it as a legacy sourcemap uploading method, and we instead encourage people to use Debug IDs, since it provides a much more straightforward and less error-prone experience. |
@szokeasaurusrex I understand. Perhaps it's possible to inject something into the ELF header of the binary and read it out in Go using |
@jerbob92 How exactly would you envision something like this working? Is there any precedent in other tool that inject something into the ELF header? |
@szokeasaurusrex I don't know, I just tried coming up with creative ideas to still get a debug ID in the binary. Do other compilers inject a debug ID in the symbol information? |
@szokeasaurusrex Doesn't the Go compiler already inject a build ID? You can extract it using |
I was unaware of this build ID since we were trying to use the DWARF debug ID (as we do for other compiled languages), which the Go compiler does not generate. The Go build ID you are mentioning seems promising, but we can only use it if there is a way to extract the build ID from the binary at runtime from within the Go program, since the Sentry Go SDK would need to send the build ID with each event so we can use the correct debug information |
Can you tell me which debug ID you are talking about? Afaik there is no "DWARF debug ID". Only thing I can find is the The code to read the build ID is here: https://github.com/golang/go/blob/master/src/cmd/internal/buildid/buildid.go |
This is precisely the problem here: Go's debug information (which is embedded in the executable) does not include a debug ID, unlike debug information files generated by other languages/compilers. |
@szokeasaurusrex what I mean is that a standardized |
@jerbob92 I am referring to the UUID that is output from the For example, if you compile a basic C program with GCC on Mac, and then pass the executable to the above command, you will obtain output that looks like so:
Rust binaries also contain a UUID like the one above. However, if you pass a compiled Go binary instead, the command exits without any output, indicating that the Go compiler does not store this same UUID in the binary. This UUID is what we use in Sentry to identify debug files. You can see that if we pass the same C binary from above to
If we instead pass a Go binary,
|
Ah, thank you for that, that's something different than the |
@szokeasaurusrex I just tried it and for me
This is on a Linux machine. It just doesn't have the So I think support for the Go build-id could be added to Symbolic by looking for I don't know why your Go binary does not have a Debug ID (maybe it has to do with DWARF issues on OSX? golang/go#62577 ). Edit: since Go 1.22 it's also possible to get the GNU build-id in there, it's derived from the Go build-id, before it was already an option to set your own GNU build-id with the With that command I have a Debug ID and a Code ID. |
@jerbob92, in that case, I am guessing this might be some kind of platform-dependent difference between Linux and Mac. I also tried using |
|
@szokeasaurusrex how do you normally get this Debug ID in exceptions or during normal runtime? Or is that not necessary to make it work? |
@jerbob92, I am unsure – that is most likely an implementation detail of the SDK sending the event |
The only way to enable source context for Go is to deploy your source code next to the binary, which is odd. We should add support for source bundles for Go as well, which gives our users more options.
The text was updated successfully, but these errors were encountered: