From 0f1ae2eb0f9e00e7531eef6f82c832947c693e6d Mon Sep 17 00:00:00 2001 From: MateuszKepczynskiSauce Date: Thu, 28 Nov 2024 08:56:53 +0100 Subject: [PATCH] feat(thread): add faulting field to thread struct (#23) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- threads.go | 3 ++- threads_test.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/threads.go b/threads.go index 2f188cb..1f49f75 100644 --- a/threads.go +++ b/threads.go @@ -8,6 +8,7 @@ import ( type Thread struct { Name string `json:"name"` + Fault bool `json:"fault"` Stacks []StackFrame `json:"stack"` } @@ -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 == "" { diff --git a/threads_test.go b/threads_test.go index d9b2c19..fec1928 100644 --- a/threads_test.go +++ b/threads_test.go @@ -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",