Created
March 12, 2018 18:58
-
-
Save caulagi/3140b0df6505d264bf1633b26e5e224f to your computer and use it in GitHub Desktop.
Example cherrypy sentry integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def register_sentry(): | |
cherrypy.tools.report_to_sentry = cherrypy.Tool('before_error_response', report_to_sentry) | |
cherrypy.config.update({ | |
'tools.report_to_sentry.on': True | |
}) | |
def report_to_sentry(): | |
sentry_dsn = settings.sentry_dsn | |
if not sentry_dsn: | |
return | |
client = raven.Client(dsn=sentry_dsn) | |
client.http_context({ | |
'method': cherrypy.request.method, | |
'url': '{}/{}'.format(cherrypy.request.base, cherrypy.request.path_info), | |
'method': cherrypy.request.method, | |
'data': dict(cherrypy.request.body), | |
'query_string': cherrypy.request.query_string, | |
'headers': dict(cherrypy.request.headers), | |
}) | |
client.captureException() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment