Skip to content

Instantly share code, notes, and snippets.

@caulagi
Created March 12, 2018 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caulagi/3140b0df6505d264bf1633b26e5e224f to your computer and use it in GitHub Desktop.
Save caulagi/3140b0df6505d264bf1633b26e5e224f to your computer and use it in GitHub Desktop.
Example cherrypy sentry integration
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