Closed anlu closed 2 years ago
@anlu sorry for the long delay getting back to you.
Your investigation was spot on. That is exactly what is happening, we are using a reference to mw_path
which is updated by the loop, so all function middleware share the same resource name.
I have a fix available in #2884 that will resolve this.
Thank you for reporting!!
@anlu this is now released in ddtrace==0.53.3
, please let us know if the issue continues!
Which version of dd-trace-py are you using?
0.53.2
Which version of pip are you using?
21.2.3
Which version of the libraries are you using?
How can we reproduce your problem?
What is the result that you get?
What is the result that you expected?
Set up a Django app with multiple function (not class based) middlewares. Make a request to any view. Observe that the Datadog APM spans for all function based middlewares are labeled with the last middleware as set in the Django MIDDLEWARE configuration variable in settings.py. They should be labeled correctly.
I believe the error lies in the delayed evaluation of the
mw_path
variable here, when it has already finished iterating oversettings_middleware
.https://github.com/DataDog/dd-trace-py/blob/v0.53.2/ddtrace/contrib/django/patch.py#L260