Skip to content
This repository was archived by the owner on Aug 17, 2020. It is now read-only.

Commit b0809dd

Browse files
authored
Adds panic stacktraces inside the logs (#202)
1 parent 94f35e3 commit b0809dd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

init.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"testing"
1212

1313
"go.undefinedlabs.com/scopeagent/agent"
14+
"go.undefinedlabs.com/scopeagent/errors"
1415
"go.undefinedlabs.com/scopeagent/instrumentation"
1516
"go.undefinedlabs.com/scopeagent/instrumentation/logging"
1617
scopetesting "go.undefinedlabs.com/scopeagent/instrumentation/testing"
@@ -52,11 +53,11 @@ func Run(m *testing.M, opts ...agent.Option) int {
5253
os.Exit(1)
5354
}()
5455
reflection.AddPanicHandler(func(e interface{}) {
55-
instrumentation.Logger().Printf("Panic handler triggered by: %v,\nFlushing agent, sending partial results...", e)
56+
instrumentation.Logger().Printf("Panic handler triggered by: %v.\nFlushing agent, sending partial results...", errors.GetCurrentError(e).ErrorStack())
5657
newAgent.Flush()
5758
})
5859
reflection.AddOnPanicExitHandler(func(e interface{}) {
59-
instrumentation.Logger().Printf("Process is going to end by: %v,\nStopping agent...", e)
60+
instrumentation.Logger().Printf("Process is going to end by: %v,\nStopping agent...", errors.GetCurrentError(e).ErrorStack())
6061
scopetesting.PanicAllRunningTests(e, 3)
6162
newAgent.Stop()
6263
})

0 commit comments

Comments
 (0)