-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
CallerSkip does not apply to stacktraces captured by zap #512
Comments
* Skip frames as configured in stacktraces * Add `StackSkip()` to manually retrieved a pruned stacktrace * Remove "zip" package pruning in `takeStacktrace()` fixes uber-go#512
* Skip frames as configured in stacktraces * Add `StackSkip()` to manually retrieved a pruned stacktrace * Remove "zip" package pruning in `takeStacktrace()` fixes uber-go#512
* Skip frames as configured in stacktraces * Add `StackSkip()` to manually retrieved a pruned stacktrace * Remove "zip" package pruning in `takeStacktrace()` fixes uber-go#512
* Honor StackSkip option when including stacktrace. * Replace package-based stack pruning - the same behavior is achieved by skipping frames appropriately. fixes uber-go#512
* Honor StackSkip option when including stacktrace. * Replace package-based stack pruning - the same behavior is achieved by skipping frames appropriately. fixes uber-go#512
On balance, I'd prefer to leave the stacktraces as complete as possible. Managing caller skips is really finicky - we've made mistakes ourselves when wrapping and unwrapping loggers internally. It's not the end of the world when the caller reported in the logs is incorrect, but it'd be a real pain if we mistakenly trimmed off too many stack frames. Even the trimming functionality we have today is a bit unusual - most other libraries I've seen (including ones in other languages) seem to bias toward more-complete stack traces. Sentry and similar tools highlight stack frames from the application code, so I don't think including extra information is too harmful. I'll leave this open for a bit longer so we can ruminate. |
I think it's very nice. This is very important. because the invalid log is too much. @akshayjshah It is not very convenient to find bug. |
I know this is an old issue, but I've just been reading through this and reviewed what #525 was trying to achieve. I understand why the PR was closed, but how about an alternative solution of allowing users to add custom prefixes to omit from stacktraces? This would mean there wouldn't be any breaking changes to existing users as it would be opt-in by providing said prefixes. For context, I'm using https://github.com/go-logr/zapr and would like to omit the stacks from this wrapper, similar to the OP |
While we can add the ability to omit specific prefixes, I think it may be better to align the caller skip with the stack trace collection, so users don't have to opt-in to prefix stripping, as well as increasing the caller skip. |
* UseCallerSkipForStacktrace configures the Logger to honor CallerSkip when taking stacktraces. * StackSkip is similar to Stack but allows skipping frames from the top of the stack Fixes uber-go#512, fixes uber-go#727
…843) * Honor `CallerSkip` when taking a stack trace. Both the caller and stack trace will now point to the same frame. * Add `StackSkip` which is similar to `Stack` but allows skipping frames from the top of the stack. This removes the internal behavior of skipping zap specific stack frames when taking a stack trace, and instead relies on the same behavior used to calculate the number of frames to skip for getting the caller to also skip frames in the stack trace. Fixes #512, fixes #727
…ber-go#843) * Honor `CallerSkip` when taking a stack trace. Both the caller and stack trace will now point to the same frame. * Add `StackSkip` which is similar to `Stack` but allows skipping frames from the top of the stack. This removes the internal behavior of skipping zap specific stack frames when taking a stack trace, and instead relies on the same behavior used to calculate the number of frames to skip for getting the caller to also skip frames in the stack trace. Fixes uber-go#512, fixes uber-go#727
Currently, logging wrappers use
CallerSkip
to avoid the logging wrapper showing up as the caller. However, this is not used by stacktraces, so we end up with the logging wrappers showing up in stacktraces.@akshayjshah: I'm thinking we should respect caller skip in stacktraces as well, any thoughts?
The text was updated successfully, but these errors were encountered: