Skip to content
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

Add CompactUserMessage() and StackTraceReport() #110

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hugoShaka
Copy link

@hugoShaka hugoShaka commented Nov 28, 2024

This PR adds a couple of new functions in an attempt to improve error logging in teleport projects.
The goal is not to make trace/v2, I tried a year ago and was not convinced by the result. I have not given up on making trace more aligned with go's wrapping and will likely resurrect the RFD at some point.

This PR introduces new functions instead of changing TraceErr.Error(), this ensures the changes can be backported (this is a requirement for the teleport-updater). This also allows us to experiment with error formats before doing a trace/v2.

The main motivation for this PR is to have user-friendly error logging in the teleport-updater. During the implementation, I found the great loggin RFD written by @programmerq . While I'm not trying to implement it completely, the changes this PR proposes are aligned with the RFD suggestions of making shorter single-line error messages and decluttering the stacktrace debug report.

The goal is to:

provide concise go-style error messages for wrapped error:

The standard go practice is to wrap with fmt.Errorf("callsite info: %w", err). This creates error messages looking like callsite info: my error message. The error message fits in a single line and is friendly both for JSON logging and Text logging. Multiline errors add \n in the first and clutters the log output in the latter.

improved structured logging support for traced errors

Currently the trace is contained in the DebugReport, a large multiline string that was intended for CLI troubleshooting. Debug reports are currently not logged properly by the JSON logger, and clutter the server logs when used with the Text logger. Exposing the structured trace will allow the structured logger to log it properly, regardless of the logging output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants