This repository was archived by the owner on Aug 30, 2023. It is now read-only.
Add interface for custom source code loaders #207
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rationale
We'd like to send source code context into Sentry alerts along with stacktraces. This works on localhost or on machines that have the source code available on the file system.
But we don't want to ship the source code of our repository in plain text as part of the Docker image because of disk space and security reasons.
However, we still want to receive source code context in our production Sentry alerts.
Proposal
Let raven-go users define their own "storage" of the source code files.
Change the
fileContext(filename string, line, context int) ([][]byte, int)
stacktrace.go function to an implementation of a new interface:Example of custom source code loader
We plan to embed the source code into the binary via https://github.com/shurcooL/vfsgen and implement the interface on top of
http.FileSystem
.The custom loader can be built on anything that can provide source code, either if it's static files built into binaries (like vfsgen, packer etc.), or an implementation that pulls the source code directly from Github.