Search code examples
sentrydjango-1.7raven

Prevent root cause message from being truncated (too much) in Sentry


I use Sentry to monitor exceptions in my Django 1.7 application.

Here is the raven config:

RAVEN_CONFIG = {
    'dsn': get_env_variable('SENTRY_DSN'),
    'string_max_length': 10000,
}

I have a feature which sends an email in response to an JSON API call. Here where things are logged in the view:

try:
    msg = send_email(json_obj)
except InvalidEmailDataError:
     logger.exception("Impossible to send email because bad data were sent")
     return HttpResponseBadRequest()

inside send_email, json_obj is validated against a schema, and a violation ends up with a InvalidEmailDataError with a quite long message, which is needed to understand what went wrong.

The problem is that the message is consistently truncated at 508 characters, which prevents me to provide useful information to the team who calls the API.

The dialog is basically:

  • Me: Your JSON is wrong.
  • Them: Ok, what is wrong exactly ?
  • Me: I don't know, sorry.

How can I get out of this situation, or more precisely, what truncates the message of the root exception to 508 characters ?


Solution

  • You can see here that sentry has server limits to message length. I'm sure these are changing over time, and I don't know what they are presently set to. I agree this is pretty frustrating for a logging platform. This is probably a business decision made so they can save money on storage costs.