-
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
Add an option for setting stack skip #727
Comments
@segevfiner Would the |
That's only for the caller, we need something similar for the stack trace. Those two will have similar functionality so we might want to consider that it's likely the user will want to set both to the same value. So maybe we should also have an |
Yes, I need the same feature as how java does, find maxDepthPerThrowable in https://github.com/logstash/logstash-logback-encoder/tree/logstash-logback-encoder-6.3#customizing-stack-traces |
This is similar to the request in #512 I agree that aligning caller skip and stack traces makes sense, but there's also some concerns on backwards compatibility. I think adding an option to align the caller skip and stack trace pruning might be a good way to solve this problem. |
* 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
Sometimes you log from internal functions and want the stack trace to point to their caller, for example: a panic recovery middleware/wrapper. This is especially important when directing errors logged to zap to an error collection service such as Sentry/Rollbar/Bugsnag/etc as they rely on the stack trace to identify and merge similar errors.
I'm proposing a new field factory
func StackSkip(key string, skip int) Field
that also allows controlling the stack skip, that is the number of frames to skip from the top of the stack. And a new optionfunc SetStackSkip(skip int) Option
that can be used to set the stack skip for the automatic stack traces.The text was updated successfully, but these errors were encountered: