diff --git a/newrelic/core/environment.py b/newrelic/core/environment.py index e1838dfba7..c3b9125626 100644 --- a/newrelic/core/environment.py +++ b/newrelic/core/environment.py @@ -152,7 +152,7 @@ def environment_settings(): dispatcher.append(("Dispatcher", "gunicorn (gevent)")) elif "gunicorn.workers.geventlet" in sys.modules: dispatcher.append(("Dispatcher", "gunicorn (eventlet)")) - elif "uvicorn.workers" in sys.modules: + elif "uvicorn.workers" in sys.modules or "uvicorn_worker" in sys.modules: dispatcher.append(("Dispatcher", "gunicorn (uvicorn)")) uvicorn = sys.modules.get("uvicorn") if hasattr(uvicorn, "__version__"): diff --git a/tests/agent_unittests/test_environment.py b/tests/agent_unittests/test_environment.py index 84dd753a9a..8f121fa060 100644 --- a/tests/agent_unittests/test_environment.py +++ b/tests/agent_unittests/test_environment.py @@ -113,6 +113,17 @@ def test_plugin_list_uses_no_sys_modules_iterator(monkeypatch): "1.2.3", "4.5.6", ), + # New replacement module uvicorn_worker should function the same + ( + { + "gunicorn": module("1.2.3"), + "uvicorn": module("4.5.6"), + "uvicorn_worker": object(), + }, + "gunicorn (uvicorn)", + "1.2.3", + "4.5.6", + ), ({"uvicorn": object()}, "uvicorn", None, None), ( {