Skip to content

Instantly share code, notes, and snippets.

@felipe-prenholato
Created September 20, 2012 14:03
Show Gist options
  • Save felipe-prenholato/3756123 to your computer and use it in GitHub Desktop.
Save felipe-prenholato/3756123 to your computer and use it in GitHub Desktop.
Snippet to create errors with complete info in sentry
import sys, logging
exc_info = sys.exc_info()
# this is important to get request info like url, browser, etc.
data = sentry_cli.get_data_from_request(request)
# and this to say what level of msg (error in case) and module of app current app
data.update({
'level': logging.ERROR,
'logger': __name__,
})
# than in extra you put all additional info u want.
extra = {
'extra': {
'record': record,
'row': row,
'col': col,
'field info': field,
},
}
# send, and get the error id
sentry_msg_id = sentry_cli.get_ident(
sentry_cli.captureException(exc_info=exc_info,
data=data, **extra)
)
# clean garbage
del exc_info
del extra
del data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment