fix: Set either Frame.Filename or Frame.AbsPath #233
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.
Despite the name "filename", the field is supposed to contain "The path to the source file relative to the project root directory." [1]
Setting
Frame.Filename
tofilepath.Base(FrameAbsPath)
is a problem because it creates ambiguous paths and may affect the "Suspect Commits" feature.Depending on how the binary is built, the Go runtime knows either the absolute path or the relative path of source files.
In the general case, it can be difficult to derive a correct "project-relative" path. Code built using Go Modules can be anywhere in the file system (not only under GOPATH). GOPATH can be multiple paths.
There was an attempt to trim paths in
raven-go
[2], but the approach there relies on GOROOT and GOPATH as configured for "future builds", and does not reflect how the running binary has been built, thus not being a good general case solution.For now we set either
Filename
orAbsPath
depending on what is known, and we leave figuring out a relative path from an absolute path for a later improvement.[1] https://develop.sentry.dev/sdk/event-payloads/stacktrace#frame-attributes
[2] https://github.com/getsentry/raven-go/blob/5c24d5110e0e198d9ae16f1f3465366085001d92/stacktrace.go#L141
Fixes #216.