-
Notifications
You must be signed in to change notification settings - Fork 137
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
Log Django 404s using a separate middleware that hooks in to process_response #123
Comments
Hey @atbaker, we're actually looking at reworking our Django middleware a bit this week. I'll get back to you once we do that. |
I'm going to file an internal ticket for us to add a 404-capture middleware (or add it to the existing middlware). |
@jasonm of course - we always welcome pull requests! You could make another Rollbar middleware solely to catch 404's. It should also be possible to change the order in which Django middleware executes. However, I believe the execution order has slightly changed since 1.10. |
@ezarowny @atbaker Something along these lines? I'll give this a spin in our app. https://gist.github.com/jasonm/29c34915c0100c13082d3ab9c9bec170 |
That's pretty good! I'd probably want to add a configurable blacklist or whitelist as well. |
FWIW what I found is that, similar to The Here is a new gist with the classes I eventually used: |
FWIW this |
Hi there, I’m closing out all issues opened before 2018 that haven’t had any activity on them since the start of this year. If this is still an issue for you, please comment here and we can reopen this. Thanks! |
This is still an issue. Were you not planning on addressing it? |
@dprothero we recently closed out a lot of our older issues, but since it's still affecting you, we've reopened it and added it to our backlog. |
Howdy,
First - thanks for supporting and maintaining this library. Overall, Rollbar has worked out well for our Django site.
We're having trouble accurately reporting 404s, however. We're using Wagtail, a Django-based CMS. Wagtail has a
redirects
middleware which is almost identical to Django's contrib redirects middleware.Both middlewares use
process_response
to catch responses with 404 error codes and check to see if a user-defined redirect is available for them.If your view still throws a
Http404
exception, however, Rollbar's middleware will see and report the exception before any other middleware'sprocess_response
method has an opportunity to redirect the response. This happens regardless of the middleware order.Because of this, our Rollbar dashboard has a ton of 404 warnings reported, but only a minority of them are valid - many are caught by the redirect middleware.
I was looking for solutions. It looks like Sentry solves this problem by providing a separate middleware for logging 404s and putting it at the top of the middleware stack: https://docs.getsentry.com/hosted/clients/python/integrations/django/#logging
We're going to keep using Rollbar to log 404s, even though our 404 logging data is noisy. But it would be great if there was some way I could accurately report 404s from our Django app.
Thanks.
The text was updated successfully, but these errors were encountered: