-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/httpclient
- Loading branch information
Showing
10 changed files
with
147 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//go:build !go1.21 | ||
|
||
package sentry | ||
|
||
func cleanupFunctionNamePrefix(f []Frame) []Frame { | ||
return f | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//go:build !go1.21 | ||
|
||
package sentry | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func Test_cleanupFunctionNamePrefix(t *testing.T) { | ||
f := []Frame{ | ||
{Function: "main.main"}, | ||
{Function: "main.main.func1"}, | ||
} | ||
got := cleanupFunctionNamePrefix(f) | ||
assertEqual(t, got, f) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//go:build go1.21 | ||
|
||
package sentry | ||
|
||
import "strings" | ||
|
||
// Walk backwards through the results and for the current function name | ||
// remove it's parent function's prefix, leaving only it's actual name. This | ||
// fixes issues grouping errors with the new fully qualified function names | ||
// introduced from Go 1.21. | ||
|
||
func cleanupFunctionNamePrefix(f []Frame) []Frame { | ||
for i := len(f) - 1; i > 0; i-- { | ||
name := f[i].Function | ||
parentName := f[i-1].Function + "." | ||
|
||
if !strings.HasPrefix(name, parentName) { | ||
continue | ||
} | ||
|
||
f[i].Function = name[len(parentName):] | ||
} | ||
|
||
return f | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//go:build go1.21 | ||
|
||
package sentry | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func Test_cleanupFunctionNamePrefix(t *testing.T) { | ||
cases := map[string]struct { | ||
f []Frame | ||
want []Frame | ||
}{ | ||
"SimpleCase": { | ||
f: []Frame{ | ||
{Function: "main.main"}, | ||
{Function: "main.main.func1"}, | ||
}, | ||
want: []Frame{ | ||
{Function: "main.main"}, | ||
{Function: "func1"}, | ||
}, | ||
}, | ||
"MultipleLevels": { | ||
f: []Frame{ | ||
{Function: "main.main"}, | ||
{Function: "main.main.func1"}, | ||
{Function: "main.main.func1.func2"}, | ||
}, | ||
want: []Frame{ | ||
{Function: "main.main"}, | ||
{Function: "func1"}, | ||
{Function: "func2"}, | ||
}, | ||
}, | ||
"PrefixWithRun": { | ||
f: []Frame{ | ||
{Function: "Run.main"}, | ||
{Function: "Run.main.func1"}, | ||
}, | ||
want: []Frame{ | ||
{Function: "Run.main"}, | ||
{Function: "func1"}, | ||
}, | ||
}, | ||
"NoPrefixMatch": { | ||
f: []Frame{ | ||
{Function: "main.main"}, | ||
{Function: "main.handler"}, | ||
}, | ||
want: []Frame{ | ||
{Function: "main.main"}, | ||
{Function: "main.handler"}, | ||
}, | ||
}, | ||
"SingleFrame": { | ||
f: []Frame{ | ||
{Function: "main.main"}, | ||
}, | ||
want: []Frame{ | ||
{Function: "main.main"}, | ||
}, | ||
}, | ||
"ComplexPrefix": { | ||
f: []Frame{ | ||
{Function: "app.package.Run"}, | ||
{Function: "app.package.Run.Logger.func1"}, | ||
}, | ||
want: []Frame{ | ||
{Function: "app.package.Run"}, | ||
{Function: "Logger.func1"}, | ||
}, | ||
}, | ||
} | ||
for name, tt := range cases { | ||
t.Run(name, func(t *testing.T) { | ||
got := cleanupFunctionNamePrefix(tt.f) | ||
assertEqual(t, got, tt.want) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package sentryhttp | ||
package sentry | ||
|
||
import ( | ||
"bufio" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package sentryhttp | ||
package sentry | ||
|
||
import ( | ||
"bufio" | ||
|