Through backlash, TurboGears supports error reporting to Sentry via Raven. Enabling the error reporting is quite easy, just add the appropriate setting in the .ini
configuration file, for example:
[DEFAULT]
debug = false
trace_errors.sentry_dsn = https://[…]
trace_slowreqs.enable = true
trace_slowreqs.sentry_dsn = https://[…]
set debug = false
According to Raven's documentation, adding more context to what gets reported should be as simple as
def handle_request(request): # In TurboGears, this would be a controller instead.
client.context.merge({'user': {
'email': request.user.email
}})
try:
...
finally:
client.context.clear()
However, now I wonder what is the easiest, or most correct, way to get hold of the client
instance that backlash
will use for reporting? I would like to add per-request information, typically from within the request handlers, or Controller
methods.