-
-
Notifications
You must be signed in to change notification settings - Fork 656
patch_cli_runner was removed and it appears that raven no longer automatically sends django command errors #884
Comments
The default sys.excepthook should capture it. With which version of Django do you see it? |
I don't have context for the original issue, but I think I may be encountering a similar problem, where exceptions in my management commands are not being captured by Raven. As an example, I created a dummy command that just raises an exception in its I've tested this on Django 1.10.3 and 1.9.9 with the same results. My Raven and logging configs are the following:
In addition, I have a custom client class (basically just a subclass of the
I've tried to investigate this issue by seeing how the custom excepthook is set up in Raven here. It appears that Please let me know if any additional information would be helpful. |
Can you paste the actual traceback you get on the console? I wonder if Django now catches those exceptions itself and reports them. |
|
I am using djanog 1.9 and raven-5.32.0. raven no longer automatically sends django command errors |
With django 1.9 and raven==5.11.0. It works perfectly. |
I am having similar problems, even when I add explicit logging calls in my manage.py - the messages are simply not being sent to Sentry:
The "Configuring Raven for host" message does not appear on the console, nor any messages about sending messages to Sentry. I have exactly the same behaviour as reported before - raven 5.23 works fine (including all the expected debug messages on the console), while 5.24 (as well as 5.32 and presumably all in between) does not work at all in this situation - whether with explicit logging calls or with sys.excepthook. I have also tried with and without this call added to my manage.py, in case there was a problem setting up logging:
but this made no difference. For reference, I'm using Django 1.8.16. My logging set up is almost exactly the same as example one - https://docs.sentry.io/clients/python/integrations/django/#integration-with-logging (obviously I have a few extra things, but nothing that should affect this). I do not have a custom SENTRY_CLIENT Is there any more information needed, or can we remove that tag? With latest Raven, and all supported Django versions, (Django 1.8 to 1.10), there doesn't seem to be any way to get Sentry integration with manage.py commands at all. |
@mitsuhiko Can we have some attention to this? For Django, latest Raven client (up to 5.32.0) does not send any messages to Sentry outside request/response cycle. |
@spookylukey i think this is largely just blocked because it's not clear how to solve it. Why does this not bubble up to the default except hook. Did this change in Django? |
@mitsuhiko trying to debug this further, I can't reproduce my exact problem with a barebones Django project - namely, all logging through Sentry with client 5.24 and greater doesn't send messages. This ought to have been easier to debug, there must be some issue specific to my setup. Debugging the default except hook thing might be harder, I don't know how to start with that. |
@mitsuhiko After a brief investigation, it looks like the default sys.excepthook is not being successfully patched by raven when using management commands. As a result, raven's custom exception handling is not being triggered. The patching of sys.excepthook appears to only happen when the raven Client is instantiated ( Line 216 in c69abaa
__init__ method, and I also printed sys.excepthook from within the command's handle method and it displayed the default <built-in function excepthook> rather than the expected <function handle_exception at ...> ).
Is there a way to force the Client to be instantiated as part of bootstrapping the management command? |
Since the conversation around this is sparse, here is the issue:
I'm not sure the most effective solution off hand, as its either "import raven to initialize it" or we once again have to monkey patch various things. I think one issue here is that our code isnt being imported at all here. It's possible its as easy as importing our runtime code in the |
FYI I'm working on a patch for this. I think we can just hook apps in 1.7+ and runtime patch in older versions. |
- utilize app.ready() for Django 1.7+ - ensure client is instantiated upon initialization (fixes sys.except_hook) Fixes GH-884
Hello, I see this issue is marked as closed. With recent Django and Raven versions, should the exceptions from management commands get reported to Sentry? Are there any additional steps to set them up? I tested with this simple command:
I got a traceback in console but nothing in Sentry website. I did not see "Sentry is attempting to send 1 pending error messages" output either. I tested with Django 1.10.5 and 1.11, and with Sentry 6.0.0. Exceptions from request-response cycle do get reported. |
I guess this was fixed on the 5.x branch, and also on master for 6.x, but we haven't yet cut 6.1 with this fix. Unsure what is blocking this tag though. |
Thank you for the quick response! |
No description provided.
The text was updated successfully, but these errors were encountered: