Skip to content

Commit

Permalink
Remove change from v1, add Changelog and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
DariaKunoichi committed Feb 29, 2024
1 parent 4fc85cb commit 86f1abe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* Start showing inlined functions in stack trace
[#208](https://github.com/bugsnag/bugsnag-go/pull/208)

* Stop trimming everything before "main.go" on main packages
[#217](https://github.com/bugsnag/bugsnag-go/pull/217)
[Chris Duncan](https://github.com/veqryn)

## 2.2.0 (2022-10-12)

### Enhancements
Expand Down
2 changes: 1 addition & 1 deletion event.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func generateStacktrace(err *errors.Error, config *Configuration) []StackFrame {
inProject := config.isProjectPackage(frame.Package)

// remove $GOROOT and $GOHOME from other frames
if idx := strings.Index(file, frame.Package); idx > -1 && frame.Package != "main" {
if idx := strings.Index(file, frame.Package); idx > -1 {
file = file[idx:]
}
if inProject {
Expand Down
5 changes: 1 addition & 4 deletions v2/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@ func (config *Configuration) isProjectPackage(_pkg string) bool {
}

func (config *Configuration) stripProjectPackages(file string) string {
trimmedFile := file
if strings.HasPrefix(trimmedFile, config.SourceRoot) {
trimmedFile = strings.TrimPrefix(trimmedFile, config.SourceRoot)
}
trimmedFile := strings.TrimPrefix(file, config.SourceRoot)
for _, p := range config.ProjectPackages {
if len(p) > 2 && p[len(p)-2] == '/' && p[len(p)-1] == '*' {
p = p[:len(p)-1]
Expand Down
11 changes: 10 additions & 1 deletion v2/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,19 @@ func generateStacktrace(err *errors.Error, config *Configuration) []StackFrame {
file := frame.File
inProject := config.isProjectPackage(frame.Package)

// remove $GOROOT and $GOHOME from other frames
// This will trim path before package name for external packages and golang default packages
// Excluding main package as it's special case
// This will NOT trim paths for packages in current module because path won't contain the package name
// Example: path is "/user/name/work/internal/internal.go" and module package name is "example.com/mymodule/internal"
if idx := strings.Index(file, frame.Package); idx > -1 && frame.Package != "main" {
file = file[idx:]
}

// This should trim path for main and other current module packages with correct config
// If input path is "/user/name/work/internal/internal.go"
// SourceRoot is "/user/name/work" and ProjectPackages are []string{"main*", "example.com/mymodule/**"}
// Then when package name is "example.com/mymodule/internal"
// The path will be trimmed to "/internal/internal.go"
if inProject {
file = config.stripProjectPackages(file)
}
Expand Down

0 comments on commit 86f1abe

Please sign in to comment.