-
Notifications
You must be signed in to change notification settings - Fork 510
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
Save stack traces from logging stack_info=True #1204
Comments
Hello @pdewacht ! Thanks for bringing this up. It makes sense, we will look into this. |
Apologies if this is too much "me too" but I wanted to raise a specific use case here to make sure it's considered. Right now I get error strings via a callback. I log those error strings to get them into sentry. Many of them fingerprint differently, because they have specific details in them which cause the logged message to change. E.g. "Frobnicator 0x3124 coolant leak on valve 15" is not grouped with "Frobnicator 0x4671 coolant leak on valve 2". I was hoping to be able to send stacks with the logged messages, so that similar stacks would be grouped together. Right now each item comes as its own separate sentry issue. |
I was expecting I found this answer https://stackoverflow.com/a/46841264/202168 suggesting that maybe Just wanted to see what is the intended behaviour - should |
Hi @antonpirker I wanted to add some feedback from a recent ticket in Zendesk (#66078) about Sentry's default interaction with logging.exception() compared to a service like logz.io:
To get the stacktrace with the Sentry SDK you need to utilize the attach_stacktrace option however this would attach stacktraces to all logging.* calls. This seems to be because Sentry SDK appears to treat calls to logging.exception(msg) the same as sentry.capture_message(msg). One brainstormed solution would be to only include a stacktrace if it's included in the logging as suggested above. Another would be to make attach_stacktrace configurable by event level (i.e. debug, info, warn, error) with a backwards compatible default. |
Is there any update on plans to address this? Not including a stack trace with Thanks. |
Hello! Yes, having the stack trace included when using We have a lot on our plate right now, so we will not be able to implement this sooner then later. But we are always happy to accept PRs if someone wants to help implementing this! |
Just found this issue having recently wanted this feature. Currently I'm mimicking this with some logic in my # Based on logic from `sentry_sdk/client.py`'s `_Client._prepare_event`
with sentry_sdk.utils.capture_internal_exceptions():
__traceback_hide__ = True # noqa: F841 # Tell Sentry not to include this frame
event['threads'] = {
'values': [
{
'stacktrace': sentry_sdk.utils.current_stacktrace(with_locals=False),
'crashed': False,
'current': True,
},
],
} Something I found odd was that using |
Maybe it's been fixed since but according to Sentry's docs it should
Although that's definitely a non-standard behaviour, the logging docs hint that
|
Is it possible to add stack trace to a message, when using |
Hey @masimo12358, not on a per message basis (unless you add it yourself in |
Python's logging module has an option to attach a stack trace to a logging message:
This stack trace is lost when logging to Sentry. It'd be very helpful to have it available.
The text was updated successfully, but these errors were encountered: