Skip to content

Commit

Permalink
feat(thread): add faulting field to thread struct (#23)
Browse files Browse the repository at this point in the history
The faulting thread in the stack trace algorithm should set a
“faultingThread” boolean variable. This variable allows to indicate
which one thread is causing the issue - also behind the scene, this
thread will be used to generate a fingerprint and error description.
  • Loading branch information
MateuszKepczynskiSauce authored Nov 28, 2024
1 parent 0352f18 commit 0f1ae2e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion threads.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

type Thread struct {
Name string `json:"name"`
Fault bool `json:"fault"`
Stacks []StackFrame `json:"stack"`
}

Expand Down Expand Up @@ -41,7 +42,7 @@ func ParseThreadsFromStack(stackTrace []byte) (map[string]Thread, map[string]Sou
lines := strings.Split(stackText, "\n")

sf := StackFrame{}
thread := Thread{Name: strings.TrimSuffix(lines[0], ":")}
thread := Thread{Name: strings.TrimSuffix(lines[0], ":"), Fault: threadID == 0}
for i := 1; i < len(lines); i++ {
line := strings.TrimSpace(lines[i])
if line == "" {
Expand Down
3 changes: 2 additions & 1 deletion threads_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ func TestParseThreadsFromStack(t *testing.T) {
},
wantThreads: map[string]Thread{
"0": {
Name: "goroutine 1 [running]",
Name: "goroutine 1 [running]",
Fault: true,
Stacks: []StackFrame{
{
FuncName: "GetStack",
Expand Down

0 comments on commit 0f1ae2e

Please sign in to comment.