Python Raven and composite WSGI application

Hi,

I have a pyramid application that wrap a pylons wsgi application.

Pylons application has a sentry middleware in its own pipeline, I wanted to move the middleware higher up the stack to pyramid application.

That means however that pylons error handler will prevent exceptions from bubbling up higher up the stack.

So my idea is to run two middlewares - one for pylons, one for pyramid, that should work but there is one thing I’m unsure of - should I create two instances of sentry client for middlewares or should both middlewares share single client instance?

I think you’d prefer to share an instance. That way you can set various context at different scopes and it’s all inherited for any event within the callstack.

1 Like

KK, so basicly first create client on app init, and then pass it to both middlewares?

Yeah - create it globally somewhere. If you’re able to use the new SDK it should make it somewhat easy to have a singleton and manage scoped context correctly between threads or concurrent requests. If you’re on the old SDK it should still work fine with threads but less so evented code.