-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Change to defra errors and handle errors stacktrace #794
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks :)
@@ -102,7 +103,8 @@ func TestLogWritesFatalMessageWithStackTraceToLogAndKillsProcessGivenStackTraceE | |||
assert.Equal(t, logMessage, logLines[0]["msg"]) | |||
assert.Equal(t, "FATAL", logLines[0]["level"]) | |||
assert.Equal(t, "TestLogName", logLines[0]["logger"]) | |||
assert.Contains(t, logLines[0], "stacktrace") | |||
// no stacktrace will be present since no error was sent to the logger. | |||
assert.NotContains(t, logLines[0], "stacktrace") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Thanks :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!
@orpheuslummis that's a different thing. The HTTP API has it's own stacktrace handling from how I had implemented it. I'll open an issue to change it after this is merged. Also the formatting isn't taken into account with the logger. Formatting would be taken into account with a log analysis UI though. |
noticing: one thing that puzzles me is that the stacktraces now includes asm exit code, whereas i'm pretty sure it didn't before
|
issue: e.g.
prettified: {
"stacktrace": "OK. Stack: /Users/o/dev/defradb/cli/ping.go:29 (0x105676845)\n\tglob..func7: log.FeedbackErrorE(cmd.Context(), \"OK\", errors.New(\"OK\"))\n/Users/o/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:856 (0x104b25b84)\n\t(*Command).execute: if err := c.RunE(c, argWoFlags); err != nil {\n/Users/o/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974 (0x104b26174)\n\t(*Command).ExecuteC: err = cmd.execute(flags)\n/Users/o/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:902 (0x105673c24)\n\tExecute: _, err := c.ExecuteC()\n/Users/o/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:895 (0x105673c1d)\n\t(*Command).ExecuteContext: return c.Execute()\n/Users/o/dev/defradb/cli/cli.go:43 (0x105673bed)\n\tExecute: err := rootCmd.ExecuteContext(ctx)\n/Users/o/dev/defradb/cmd/defradb/main.go:18 (0x10567c270)\n\tmain: cli.Execute()\n/opt/homebrew/Cellar/go@1.18/1.18.6/libexec/src/runtime/proc.go:250 (0x10496acf0)\n\tmain: fn()\n/opt/homebrew/Cellar/go@1.18/1.18.6/libexec/src/runtime/asm_arm64.s:1270 (0x104999634)\n\tgoexit: MOVD\tR0, R0\t// NOP\n",
"Error": "OK",
"ErrorVerbose": "OK. Stack: /Users/o/dev/defradb/cli/ping.go:29 (0x105676845)\n\tglob..func7: log.FeedbackErrorE(cmd.Context(), \"OK\", errors.New(\"OK\"))\n/Users/o/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:856 (0x104b25b84)\n\t(*Command).execute: if err := c.RunE(c, argWoFlags); err != nil {\n/Users/o/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974 (0x104b26174)\n\t(*Command).ExecuteC: err = cmd.execute(flags)\n/Users/o/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:902 (0x105673c24)\n\tExecute: _, err := c.ExecuteC()\n/Users/o/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:895 (0x105673c1d)\n\t(*Command).ExecuteContext: return c.Execute()\n/Users/o/dev/defradb/cli/cli.go:43 (0x105673bed)\n\tExecute: err := rootCmd.ExecuteContext(ctx)\n/Users/o/dev/defradb/cmd/defradb/main.go:18 (0x10567c270)\n\tmain: cli.Execute()\n/opt/homebrew/Cellar/go@1.18/1.18.6/libexec/src/runtime/proc.go:250 (0x10496acf0)\n\tmain: fn()\n/opt/homebrew/Cellar/go@1.18/1.18.6/libexec/src/runtime/asm_arm64.s:1270 (0x104999634)\n\tgoexit: MOVD\tR0, R0\t// NOP\n",
"stacktrace": "OK. Stack: /Users/o/dev/defradb/cli/ping.go:29 (0x105676845)\n\tglob..func7: log.FeedbackErrorE(cmd.Context(), \"OK\", errors.New(\"OK\"))\n/Users/o/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:856 (0x104b25b84)\n\t(*Command).execute: if err := c.RunE(c, argWoFlags); err != nil {\n/Users/o/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974 (0x104b26174)\n\t(*Command).ExecuteC: err = cmd.execute(flags)\n/Users/o/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:902 (0x105673c24)\n\tExecute: _, err := c.ExecuteC()\n/Users/o/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:895 (0x105673c1d)\n\t(*Command).ExecuteContext: return c.Execute()\n/Users/o/dev/defradb/cli/cli.go:43 (0x105673bed)\n\tExecute: err := rootCmd.ExecuteContext(ctx)\n/Users/o/dev/defradb/cmd/defradb/main.go:18 (0x10567c270)\n\tmain: cli.Execute()\n/opt/homebrew/Cellar/go@1.18/1.18.6/libexec/src/runtime/proc.go:250 (0x10496acf0)\n\tmain: fn()\n/opt/homebrew/Cellar/go@1.18/1.18.6/libexec/src/runtime/asm_arm64.s:1270 (0x104999634)\n\tgoexit: MOVD\tR0, R0\t// NOP\n"
} |
issue: even when the stacktrace option is disabled in configuration, the stacktrace is still included in the |
2ddb043
to
59ebf79
Compare
@orpheuslummis the points you brought up are all taken care of with the latest commit. Let me know if you're happy with the changes and I'll merge. |
Codecov Report
@@ Coverage Diff @@
## develop #794 +/- ##
===========================================
+ Coverage 59.55% 59.58% +0.03%
===========================================
Files 154 154
Lines 17219 17245 +26
===========================================
+ Hits 10254 10275 +21
- Misses 6039 6044 +5
Partials 926 926
|
seems like an issue: when e.g. log.ErrorE(cmd.Context(), "err msg", fmt.Errorf("WRAP: %w", errors.New("an error"))) ->
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
71bc966
to
58862bf
Compare
…work#794) Description This PR moves our error handling from the standard library errors package to our own errors package. It also removes the logger stacktrace default which logs the stacktrace at the line of logging and introduces stacktrace logging from the creation of the error.
Relevant issue(s)
Resolves #750
Resolves #751
Description
This PR moves our error handling from the standard library errors package to our own errors package. It also removes the logger stacktrace default which logs the stacktrace at the line of logging and introduces stacktrace logging from the creation of the error.
Tasks
How has this been tested?
unit tests
Specify the platform(s) on which this was tested: