-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
We noticed that our instrumented Starlette application does not show up in Dynatrace. The issue seems to be in the instrumentation code at autodynatrace/wrappers/starlette/wrapper.py
:
def instrument():
@wrapt.patch_function_wrapper("starlette.responses", "Response.__init__")
def starlette_parsing_dynatrace(wrapped, instance, args, kwargs):
# FastAPI creates a empty response at the beginning of a request, ignore it
if kwargs.get("status_code") is None:
return wrapped(*args, **kwargs)
logger.debug("Tracing starlette.Response.__init__")
with sdk.trace_custom_service("Response.render", "starlette"):
return wrapped(*args, **kwargs)
The first if statement checks for a status_code
argument in kwargs
on initialization of a Response
, but this is not reliable, since the status code may also be passed as normal argument. In our case, the Starlette JSONResponse
passes its constructor arguments to its superclass as positional arguments, not keyword arguments. Because of this, the tracing code is never reached.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working