Hello,
I am implementing the new python sentry SDK (we were using the raven one).
We are using Django Rest Framework (DRF)
I have this simple piece of code
with push_scope() as scope:
…scope.set_extra(‘extra_stuff’, True)
…capture_exception(Exception(‘Error’))
For the sake of testing, I copied/pasted this code into two places. In a custom Django Command and into a retrieve function of a view.
I’m using a before_send hook to customize stuff.
When the hook is called, only in the context of the view, my ‘extra_stuff’ does not exist anymore into event.extra. In the context of the command, it is still there.
There is that line:
event = Serializer().serialize_event(event)
into:
lib/python3.7/site-packages/sentry_sdk/client.py
that remove the extras that I added. Lots of stuff happen into serialize_event().
Do you have any idea what could happen ? I am confused.
Thank you very much for your time.
Hi, I am not sure about your indentation. Do you call capture_exception from within the with-statement?
Yeah the capture_exception is into my with statement. Looks like the the output of my message was trimmed.
I fixed it with dots.
Here a screen shot to be more precise.
Since you talk about tags in your thread subject, could it be that you actually needed set_tag instead of set_extra?
Darn… I was pretty sure I double checked with the tags and the extras. The tags are kept correctly. I will use them instead of the extras.
But, I was wondering, is it a wanted behaviour that the extras are somehow deleted ?
Pretty sure you will find extras at the bottom of the page under Additional Data!
Sorry for the late reply.
I found what happened. There is this constant MAX_DATABAG_BREADTH = 10 that was too low for what we sent. We have a total of 21 extras. We have 5 extras + 16 extras (probably comming from the DjangoIntegration or something like that, I can not even say).
So adding a line in our code fixed it:
sentry_sdk.serializer.MAX_DATABAG_BREADTH = 25
10 is pretty low. Is there a reason for this ?
Thanks again for your time.
There is only one integration that sets extra, which is celery. It sets a single key though.
Could you link me to an event that has this amount of (not explicitly sent) extras?
Well… it was one of our Django Middleware that was creating those “mysterious extras”. I converted the code from Raven to Sentry and I forgot .
So, with monkey patching the MAX_DATABAG_BREADTH, everything is fine now !