From eb2715bb530a4be5d5977b4a5298b0a222b3c920 Mon Sep 17 00:00:00 2001 From: Lalleh Rafeei Date: Fri, 12 Sep 2025 15:43:13 -0700 Subject: [PATCH 1/3] Add deprecation warning for modules --- newrelic/config.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/newrelic/config.py b/newrelic/config.py index cdd69671f..9699f5667 100644 --- a/newrelic/config.py +++ b/newrelic/config.py @@ -21,6 +21,7 @@ import time import traceback from pathlib import Path +from datetime import datetime import newrelic.api.application import newrelic.api.background_task @@ -1105,6 +1106,24 @@ def _module_import_hook(target, module, function): def _instrument(target): _logger.debug("instrument module %s", ((target, module, function),)) + # Deprecation warning for archived/unsupported modules + library_name = target.__package__.split(".")[0] + deprecated_modules = { + "aioredis": datetime(2022, 2, 22, 0, 0) + } + + if library_name in deprecated_modules: + _logger.warning( + "%(module)s has been archived by the developers " + "and has not been supported since %(date)s. %(module)s " + "support will be removed from New Relic in a future " + "release.", + { + "module": library_name, + "date": deprecated_modules[library_name].strftime("%B %d, %Y") + } + ) + try: instrumented = target._nr_instrumented except AttributeError: From fd25e12aaf3fcf98d5c21abc6d990b8ba8352f8a Mon Sep 17 00:00:00 2001 From: Lalleh Rafeei Date: Fri, 12 Sep 2025 18:07:49 -0700 Subject: [PATCH 2/3] Megalinter fixes --- newrelic/config.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/newrelic/config.py b/newrelic/config.py index 9699f5667..204b91dbe 100644 --- a/newrelic/config.py +++ b/newrelic/config.py @@ -20,8 +20,8 @@ import threading import time import traceback +from datetime import datetime, timezone from pathlib import Path -from datetime import datetime import newrelic.api.application import newrelic.api.background_task @@ -1108,9 +1108,7 @@ def _instrument(target): # Deprecation warning for archived/unsupported modules library_name = target.__package__.split(".")[0] - deprecated_modules = { - "aioredis": datetime(2022, 2, 22, 0, 0) - } + deprecated_modules = {"aioredis": datetime(2022, 2, 22, 0, 0, tzinfo=timezone.utc)} if library_name in deprecated_modules: _logger.warning( @@ -1118,10 +1116,7 @@ def _instrument(target): "and has not been supported since %(date)s. %(module)s " "support will be removed from New Relic in a future " "release.", - { - "module": library_name, - "date": deprecated_modules[library_name].strftime("%B %d, %Y") - } + {"module": library_name, "date": deprecated_modules[library_name].strftime("%B %d, %Y")}, ) try: From bb0fca590836d5e5cc8130ad816753163d15caa8 Mon Sep 17 00:00:00 2001 From: Lalleh Rafeei Date: Mon, 15 Sep 2025 10:54:20 -0700 Subject: [PATCH 3/3] move deprecated_modules definition to module level --- newrelic/config.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/newrelic/config.py b/newrelic/config.py index 204b91dbe..82d95ce8e 100644 --- a/newrelic/config.py +++ b/newrelic/config.py @@ -55,6 +55,8 @@ _logger = logging.getLogger(__name__) +DEPRECATED_MODULES = {"aioredis": datetime(2022, 2, 22, 0, 0, tzinfo=timezone.utc)} + def _map_aws_account_id(s): return newrelic.core.config._map_aws_account_id(s, _logger) @@ -1108,15 +1110,14 @@ def _instrument(target): # Deprecation warning for archived/unsupported modules library_name = target.__package__.split(".")[0] - deprecated_modules = {"aioredis": datetime(2022, 2, 22, 0, 0, tzinfo=timezone.utc)} - if library_name in deprecated_modules: + if library_name in DEPRECATED_MODULES: _logger.warning( "%(module)s has been archived by the developers " "and has not been supported since %(date)s. %(module)s " "support will be removed from New Relic in a future " "release.", - {"module": library_name, "date": deprecated_modules[library_name].strftime("%B %d, %Y")}, + {"module": library_name, "date": DEPRECATED_MODULES[library_name].strftime("%B %d, %Y")}, ) try: