Search code examples
pythondjangosentryraven

Change grouping of an specific exception in sentry (django)



I use raven with my django web application and i want to prevent an exception from excessive grouping as described in documentations here while preserving default behavior for other exceptions.
More concretely I have a code snippet like this somewhere in my app:

raise Exception('Nothing done for catalog #' + str(catalog_id))

in sentry i see exceptions for different catalogs grouped together because it rolls them up based on stack-traces. As i understood from docs i should use something like:

client.captureException(fingerprint=['{{ default }}', str(catalog_id)])

but i don't know where in my code it should be used.


Solution

  • client.captureException(fingerprint=['{{ default }}', str(catalog_id)]) is used inside of an except clause.

    try:
        raise Exception('Nothing done for catalog #' + str(catalog_id))
    except Exception:
        client.captureException(fingerprint=['{{ default }}', str(catalog_id)])
    

    Reference: