sentry-go
sentry-go copied to clipboard
Server-side source context
Add support for serve-side source context using source bundles. https://docs.sentry.io/workflow/debug-files/#source-context
Overview
At the moment, the Contextify Frames Integration in the SDK automatically grabs context lines when those are available nearby a running binary.
We document how this can be used when deploying to a serverless platform.
While that integration can be used in certain contexts, it won't help when you (have to) distribute binaries without source code available.
The solution is to add source context on the Sentry server, and that is done by uploading source bundles after building a program.
Development notes
Creating source bundles
Use sentry-cli to generate a zip archive with source files and a manifest:
-
~~Bump
symbolicdependency inCargo.tomlto at least https://github.com/getsentry/symbolic/commit/8f9a01756e48dcbba2e42917a064f495d74058b7~~ (edit: not needed anymore, bumped upstream). -
Run
cargo run -- difutil bundle-sources /path/to/binary... -
Inspect
manifest.jsonin source archiveunzip -p /path/to/file.src.zip manifest.json | jq -C | lesscode_idis thegnu.build-id.debug_idis a transformation fromcode_idif it exists, or otherwise a hash of the text section.See https://github.com/getsentry/symbolic/blob/@{2020.03.03}/debuginfo/src/elf.rs#L92.
References:
- https://docs.sentry.io/development/sdk-dev/event-payloads/debugmeta/
- https://github.com/getsentry/symbolic/blob/@{2020.03.03}/debuginfo/src/elf.rs#L92
- https://github.com/gimli-rs/findshlibs
TODO
On the SDK, we need:
- [ ] Send
debug_idin the event payload along with other required files in theimagesattribute. See https://docs.sentry.io/development/sdk-dev/event-payloads/debugmeta/.- [ ] Linux support
- [ ] Windows support
- [ ] macOS support
This feature would be extremely helpful, especially if /go/pk/mod was supported. 🚀
Is this work scheduled / is there going to be some other way to get the source context in stacktraces without shipping the source alongside built binaries? We love Sentry and love that feature, but we don't want to start shipping source code in our containers that hold our golang web servers just to get slightly more usable stacktraces. I know that "Stack trace linking" via Github integration is now in beta, and that for Javascript there's a way to upload source maps as part of releases, and when I squint that looks like the same thing that we'd want to do here, but whatever the implementation method I'd really like to see the surrounding code inside stacktraces on error pages.
Sharing here that another viable way to get source code context in stack traces is to use Sentry's GitHub/Gitlab integrations:
https://docs.sentry.io/product/integrations/github/#stack-trace-linking https://docs.sentry.io/product/integrations/gitlab/#stack-trace-linking
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
Hey folks, is #44525 something you could take on as part of this initiative? I'm happy to guide
@armenzg I assume we could do something with our GitHub integration.
Sample error from our profiling ingestion service https://sentry.sentry.io/issues/3908326163/ (internal link). All paths are preserved in the stack trace, so we could fetch the source context with that from a repo.