diff --git a/newrelic/hooks/adapter_uvicorn.py b/newrelic/hooks/adapter_uvicorn.py index b14c663297..ee4a1ab243 100644 --- a/newrelic/hooks/adapter_uvicorn.py +++ b/newrelic/hooks/adapter_uvicorn.py @@ -17,6 +17,13 @@ @property def loaded_app(self): + # Always use the original application until the interface is resolved in + # auto mode + if getattr(self, "interface", "") == "auto": + app = self._nr_loaded_app + while hasattr(app, "__wrapped__"): + app = app.__wrapped__ + return app return self._nr_loaded_app diff --git a/tests/testing_support/sample_asgi_applications.py b/tests/testing_support/sample_asgi_applications.py index 619ca19214..d8bd523ea1 100644 --- a/tests/testing_support/sample_asgi_applications.py +++ b/tests/testing_support/sample_asgi_applications.py @@ -63,6 +63,17 @@ async def static(scope, receive, send): return await simple_app_v3_raw(scope, receive, send) +class AppWithCallRaw: + async def __call__(self, scope, receive, send): + return await simple_app_v3_raw(scope, receive, send) + + +class AppWithCall(AppWithCallRaw): + @ASGIApplicationWrapper + async def __call__(self, scope, receive, send): + return await super(AppWithCall, self).__call__(scope, receive, send) + + simple_app_v2 = ASGIApplicationWrapper(simple_app_v2_raw) simple_app_v2_init_exc = ASGIApplicationWrapper(simple_app_v2_init_exc) simple_app_v3 = ASGIApplicationWrapper(simple_app_v3_raw)