Skip to content

Commit 84be2cc

Browse files
authored
rfc(feature): Source context via links (#74)
1 parent 05077db commit 84be2cc

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ This repository contains RFCs and DACIs. Lost?
3737
- [0071-continue-trace-over-process-boundaries](text/0071-continue-trace-over-process-boundaries.md): Continue trace over process boundaries
3838
- [0072-kafka-schema-registry](text/0072-kafka-schema-registry.md): Kafka Schema Registry
3939
- [0073-usage-of-transaction-types](text/0073-usage-of-transaction-types.md): Usage of transaction types
40+
- [0074-source-context-via-links](text/0074-source-context-via-links.md): Source context via links
4041
- [0078-escalating-issues](text/0078-escalating-issues.md): Escalating Issues
4142
- [0080-issue-states](text/0080-issue-states.md): Issue States
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
- Start Date: 2023-02-15
2+
- RFC Type: feature
3+
- RFC PR: <https://github.com/getsentry/rfcs/pull/74>
4+
- RFC Status: draft
5+
6+
# Summary
7+
8+
In situations where a source code link and a line number is available for a frame, present the link in the UI and show
9+
the source code surrounding the line.
10+
11+
# Motivation
12+
13+
The source context is currently composed of three [`Frame` attributes](https://develop.sentry.dev/sdk/event-payloads/stacktrace/#frame-attributes):
14+
15+
- `context_line` - Source code in filename at `lineno`.
16+
- `pre_context` - A list of source code lines before `context_line` (in order) – usually [`lineno - 5:lineno`].
17+
- `post_context` - A list of source code lines after `context_line` (in order) – usually [`lineno + 1:lineno + 5`].
18+
19+
Showing a source code context and a link to it (e.g. to GitHub) currently works only if the source code itself is
20+
available during symbolication, thus the attributes are filled in at that time, or if they were already sent with the event by the SDK.
21+
22+
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:
23+
24+
- Portable-PDB source-link (.NET, see [this `symbolic` issue](https://github.com/getsentry/symbolic/issues/735))
25+
- [Debuginfod servers](https://www.mankier.com/8/debuginfod#Webapi-/buildid/BUILDID/source/SOURCE/FILE) (we don’t support these yet)
26+
- SourceMaps (either embedded sourcesContent or using individual source files)
27+
- via a repository integration in combination with associated commit
28+
29+
In these cases, the actual source code is not necessary to do symbolication (as opposed to source maps and other types
30+
of obfuscated source containers) but it is useful for end-user when evaluating the issue in the UI.
31+
32+
## Related GH feature requests
33+
34+
- [Extend stack-trace linking UI](https://github.com/getsentry/sentry/issues/35608)
35+
- [Support stack trace linking when stack frames do not contain line context.](https://github.com/getsentry/sentry/issues/44015)
36+
37+
# Options Considered
38+
39+
## A | Download the source code during symbolication
40+
41+
One option is to download the source code from its link at the time the event is symbolicated, filling the context-related
42+
`Frame` attributes for each stacktrace frame, while the event is being processed.
43+
44+
### Pros
45+
46+
- Reuses existing fields (changes only needed in the `Symbolicator`).
47+
- Sources surrounding the frame line are then stored in the database, enabling [search-by-code](https://github.com/getsentry/sentry/issues/3755).
48+
- 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.
49+
50+
### Cons
51+
52+
- Downloads all frame sources even though the event/frame may never be viewed by a user.
53+
- Adds potentially tens of requests for each symbolicated event that has a source link - as many as there are in the stack trace.
54+
55+
## B | Add a source-link to the `Frame` and let the UI handle it
56+
57+
Another option is to extend `Frame` attributes with a new field, e.g. `source_link` and let UI download the source code
58+
as needed or just display the link.
59+
60+
### Pros
61+
62+
- No overhead on the server for loading sources in situations where the event/frame wouldn't be shown.
63+
- Requests to fetch the source code, if any, are made by the user browser, thus avoiding potential quota limits.
64+
65+
### Cons
66+
67+
- Sources not available in the database -> can't [search-by-code](https://github.com/getsentry/sentry/issues/3755).
68+
- Accessing private sources may be problematic. We could still show the source link, though.
69+
70+
# Selected Option - Combined approach
71+
72+
Because neither option is a clear winner, we went for a combined approach, i.e.
73+
74+
- Add a `source_link` field to the frame.
75+
- Resolve source context from remote URLs, but only for in-app frames.

0 commit comments

Comments
 (0)