raven-python icon indicating copy to clipboard operation
raven-python copied to clipboard

Clarification on Django documentation

Open itoed opened this issue 9 years ago • 2 comments

Looking at the Raven docs for Django, it's only mentioned to add raven.contrib.django.raven_compat, to INSTALLED_APPS, but nowhere is it mentioned to add raven.contrib.django.middleware.wsgi.Sentry to MIDDLEWARE_CLASSES.

Without doing that, the Sentry client context is never cleared, and some attributes may leak from one Django request to another, correct? Or is raven.middleware.Sentry.process_response supposed to be invoked by some other means?

itoed avatar Dec 12 '16 21:12 itoed

It's WSGI middleware, not Django middleware, and it is mentioned here.

The Django middleware is located in the __init__.py in the same package, but it is injected to MIDDLEWARE_CLASSES automatically here.

broundee avatar Dec 13 '16 17:12 broundee

Thanks @broundee! That comment helped a lot. The first thing I did after I read it was to update to raven 5.32.0. I should have thought to do that before reading through the code. I was on 5.19.0 and the behaviour was different then, if I'm not mistaken.

I am really curious to figure out how and when the _context of DjangoClient, or its parent Client, gets reset or cleared. I'm having a little trouble seeing how what I put in there is prevented from being available to the next request handled by that thread. Could I trouble you to shed some light in my ignorance please?

itoed avatar Dec 13 '16 18:12 itoed