Open marcoaleixo opened 2 days ago
Do we have a way to set the trace_id? Maybe an easy fix is to get the trace_id in the view level and pass as parameter to my function and do a transaction.set_trace_id(trace_id=trace_id).
But it seems that we don't have a set_trace_id thing at transaction/event level, right?
I know that we can do a Span(trace_id=myid), but passing this to ALL calls downstream is bad. 😅
Hey @marcoaleixo thanks for raising this, I will have a look!
Indeed!
I have now reproduced this with this demo application: https://github.com/antonpirker/testing-sentry/blob/main/test-django-rest-framework-streaming/mysite/api/views.py
The first span "Streaming View"
is present in the trace, but the second span "Stream Response Generator"
is missing (because it has the wrong trace id)
This is a bug. I guess it has something to do with how Django handles streaming views and what we monkey patch in Django. Sentry is probably not patching the functions in Django that are handling the streaming responses.
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.18.0
Steps to Reproduce
Here the span.trace_id will be for instance "1234"
In this function, the trace_id will be totally different.
I think that this is related the StreamingHttpResponse, because the Sentry is working fine for all my other views.
Feel free to ask more details to help in the investigation.
FROM python:3.9.18-slim-bullseye Django==4.1 djangorestframework==3.14
I'm executing my server with python manage.py runserver 0.0.0.0:8000 In production we use something like gunicorn api.wsgi -b 0.0.0.0:8081
Expected Result
The trace_id should stay the same in StreamingHttpResponse views and underlying function calls.
Actual Result
The trace_id is different between the view and underlying function calls.