-
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 to override stacktrace collection logic #514
Comments
There's no way to customize this now, but I don't mind adding an option for this. We could make a However, this wouldn't affect the output of the |
(I don't want to hijack this issue but would rather like to add a similar question and ask for a recommendation) Besides adding an option for the stacktrace-snapping functionality, is it currently already possible to modify the stack trace output? Would it work by implementing a We would like to trim off some stacks that are not adding much to the signal and are rather noise. I know trimming stacks is a inherently difficult task, but I would at least like to go give our heuristic a try. |
FWIW: It is possible to wrap the existing JSON encoder to hack stack traces. I've done this to format stacks so they get picked up by Google Cloud's Stackdriver Error Report (where it needs to look like a "real" panic). It would be much nicer to have a customization hook similar to |
Any progress/change of mind regarding adding support for the mentioned |
@FlorianLoch nope, the issue is still a valid ask and we welcome PRs! |
This PR adds a `StacktraceEncoder` type to the `EncoderConfig` struct Users can override the `EncodeStacktrace` field to configure how stacktraces are outputed This PR aims to resolve uber-go#514 by mirroring the behavior of the `EncodeCaller` field The `EncodeStacktrace` field has been inserted as a required field, and has been added to `NewDevelopmentConfig` and `NewProductionConfig` as sane defaults however, it is currently a required field and can cause a panic if a user is manually building their config without these helpers.
This PR adds a `StacktraceEncoder` type to the `EncoderConfig` struct Users can override the `EncodeStacktrace` field to configure how stacktraces are outputed This PR aims to resolve uber-go#514 by mirroring the behavior of the `EncodeCaller` field The `EncodeStacktrace` field has been inserted as a required field, and has been added to `NewDevelopmentConfig` and `NewProductionConfig` as sane defaults however, it is currently a required field and can cause a panic if a user is manually building their config without these helpers.
Stacktrace collection
While trying to implement an encoder that is compatible with GCP Stackdriver logging and also for GCP Stackdriver Error Reporting, I suspected that it's not working properly because the generated stacktrace is not compatible with what Error Reporting is expected.
The documentation says (https://cloud.google.com/error-reporting/docs/formatting-error-messages):
Go: Must be the return value of runtime.Stack()
The code in go sources (
cloud.google.com/go/errors/errors.go
) shows thatcloud.google.com/go/errors.(*Client).logInternal
indeed callsruntime.Stack
.Unfortunately, the stack is grabbed by
trackStacktrace
instracktrace.go
, and there is apparently no other way around to provide the stracktrace.Unless I'm missing something, we cannot provide the way the stacktrace is grabbed by zap
The text was updated successfully, but these errors were encountered: