- Start Date: 2023-02-15
- RFC Type: feature
- RFC PR: #74
- RFC Status: draft
In situations where a source code link and a line number is available for a frame, present the link in the UI and show the source code surrounding the line.
The source context is currently composed of three Frame
attributes:
context_line
- Source code in filename atlineno
.pre_context
- A list of source code lines beforecontext_line
(in order) – usually [lineno - 5:lineno
].post_context
- A list of source code lines aftercontext_line
(in order) – usually [lineno + 1:lineno + 5
].
Showing a source code context and a link to it (e.g. to GitHub) currently works only if the source code itself is available during symbolication, thus the attributes are filled in at that time, or if they were already sent with the event by the SDK.
There are, however, situations where we do have a URL representing the source code contents, but not the contents itself (without downloading it), for example:
- Portable-PDB source-link (.NET, see this
symbolic
issue) - Debuginfod servers (we don’t support these yet)
- SourceMaps (either embedded sourcesContent or using individual source files)
- via a repository integration in combination with associated commit
In these cases, the actual source code is not necessary to do symbolication (as opposed to source maps and other types of obfuscated source containers) but it is useful for end-user when evaluating the issue in the UI.
- Extend stack-trace linking UI
- Support stack trace linking when stack frames do not contain line context.
One option is to download the source code from its link at the time the event is symbolicated, filling the context-related
Frame
attributes for each stacktrace frame, while the event is being processed.
- Reuses existing fields (changes only needed in the
Symbolicator
). - Sources surrounding the frame line are then stored in the database, enabling search-by-code.
- May be possible to do server-side authentication (based on project/org configuration) - this would complicate the solution & caching though, as opposed to only supporting publicly available sources.
- Downloads all frame sources even though the event/frame may never be viewed by a user.
- Adds potentially tens of requests for each symbolicated event that has a source link - as many as there are in the stack trace.
Another option is to extend Frame
attributes with a new field, e.g. source_link
and let UI download the source code
as needed or just display the link.
- No overhead on the server for loading sources in situations where the event/frame wouldn't be shown.
- Requests to fetch the source code, if any, are made by the user browser, thus avoiding potential quota limits.
- Sources not available in the database -> can't search-by-code.
- Accessing private sources may be problematic. We could still show the source link, though.
Because neither option is a clear winner, we went for a combined approach, i.e.
- Add a
source_link
field to the frame. - Resolve source context from remote URLs, but only for in-app frames.