[ckan-dev] Using sentry with ckan
David Raznick
david.raznick at okfn.org
Mon Feb 17 13:46:36 UTC 2014
Hello
Yes I have got sentry working with CKAN. If you are running ckan
under apache with a wsgi file like:
https://github.com/ckan/ckan-packaging/blob/master/etc/ckan/default/apache.wsgi
You can add the following to the bottom of the file (obviously
changing the client uri):
from raven import Client
from raven.middleware import Sentry
client = Client('https://44e18489493144403f:4e7d36fe7c08e85ba065a@app.getsentry.com/18472',
name='mytestinstance')
application = Sentry(application, client=client)
from pylons.middleware import StatusCodeRedirect
#this is to make sure 404 are redirected to a page that looks nice,
normally done by setting full_stack = True
application = StatusCodeRedirect(application , [400, 404, 500])
You also have to set the ckan config file to have
full_stack = false
This will stop the pylons error middlewhere catching these errors and
therefore all errors will get to sentry.
IMiddlewhere would work but it would not catch all possible errors as
its too close to the centre of the middlewhere stack. i.e if
repoze.who for example went wrong it would not catch it. The above
approach means that it catches everything as it is the outermost app.
Thanks
David
On 17 February 2014 13:05, Samuele Santi <samuele.santi at trentorise.eu> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I was trying to use sentry (https://getsentry.com/) to get monitoring
> of exceptions on ckan; I set up raven following the standard
> configuration for pylons
> http://raven.readthedocs.org/en/latest/config/pylons.html but with no
> effect; it looks like exceptions get caught before reaching the raven
> middleware.
>
> And even the logging-based error reporting seems to have some problem,
> although it works fine if I try logging something right after setting
> up the sentry client..
>
> Is anybody else using sentry with ckan / managed to figure out how to
> make it work?
>
> Right now, I'm going to try writing a IMiddleware plugin to add the
> middleware earlier, hoping to be able to catch exceptions, but I
> wanted to see if anybody else already faced (and maybe solved) the issue..
>
>
> Cheers,
>
> - --
> Samuele Santi
>
> Trento Rise
> http://www.trentorise.eu/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.12 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQIcBAEBAgAGBQJTAgkxAAoJEGgM+6dff2m7BkkP/0EiFXueFxzp1oZuEzbRi4oM
> ThTmRcdCUXDKnNNRGkbk6m1dpRhB3NylzlYVMYCfSTVdfME0/duVOIewNYEH2gBw
> Y4f5xCl0Iv+Bmy/HXnuJjTTptWzl73q5oGiIXhy5HXZCFn/oNdGT5sSfBp2I1fWN
> pWmyKkx+5VUrfnWLx9v4lUPe3ia8utLt5BpLeINGhQKVkP+dxcLghQ5U5l06kLMj
> yCXch1kSiI61pUo2oYyoGkvx4KdgHl0iBA5QiZMkNYmc8+10NGCGCSQakcxu3de2
> K74Eog+XWZEMvE+jIOeR5ktE9vFVq+IeWOEcvQmUN/LIgojWaUPd52mjZJ1xJU8+
> 4QzMD5xFerHNN/VEAP+kGi5vWNNT6NdD297bGqEaeuEf0LmMMxGSX/xwYvAMTBNh
> XPWDhLHQA2xUCKlBOAyOaLRCsP9ZF6zll/4VMwwKLlHBgZotN+1eVe6U/PHbbsbc
> wOotIeA/paS0218vGBkfpYEG87mvsle4vvsycn7axQBbME/JBy5+rP0lBYekLcwy
> y2G+YQHcLpXfm7+r8ceFrNV7J7roVI4g7VJMZdeFlQ6DHZ2z1pqVHwqAP9scFj9A
> GLyiHX9j+dz2ispTdq+wqTRTlGzTWjS9VwBdC6WFRTGkAprolm3tKO7Emt6IuJBT
> SkDmVVH4zKs+pGDASrDL
> =eMZO
> -----END PGP SIGNATURE-----
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
More information about the ckan-dev
mailing list