0


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.

mhk
  • 386
  • 1
  • 5
  • 18
  • Why are you looking to prevent "excessive grouping"? Are you looking to be alerted to *every time* this "Nothing done for catalog" exception is hit? – ehfeng Sep 06 '17 at 18:15
  • yes. and i want the exception showed in sentry list to be classified by catalog_id – mhk Sep 10 '17 at 14:33
  • I'd actually suggest letting Sentry group (correctly), but then tagging each event with `catalog_id`. Then, you'll be able to see the distributions in the issue view sidebar and the tag view. – ehfeng Sep 14 '17 at 18:00
  • should i do this like: `client.captureException(tags={'catalog_id': str(catalog_id)})` ? – mhk Sep 16 '17 at 11:57
  • Yes, that should work. – ehfeng Oct 02 '17 at 20:47

1 Answers1

2

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:

Oluwafemi Sule
  • 36,144
  • 1
  • 56
  • 81
  • I'm confused by the default behavior of capturing all exceptions... i suspect doing this result in double reports for this exception – mhk Sep 04 '17 at 15:51
  • In the `try` block, you usually do an operation that may raise an exception. If your wanted to group just the `KeyError` exception, you can capture that into it's own group and have other exceptions go into the default group – Oluwafemi Sule Sep 04 '17 at 16:06