Loosing tags using DRF

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.

43%20PM

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!