From 46455ae0f50d446bff012f607125101c39f6197a Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Mon, 1 Jul 2024 12:41:35 +0200 Subject: [PATCH] Promote some PendingDeprecationWarning to DeprecationWarning Promote the removal of opentracing integration and the removal of logging handling to DeprecationWarnings. Refs #2029 --- elasticapm/contrib/django/handlers.py | 4 ++-- elasticapm/contrib/flask/__init__.py | 2 +- elasticapm/contrib/opentracing/__init__.py | 4 ++-- elasticapm/handlers/logging.py | 11 ++++------- tests/handlers/logging/logging_tests.py | 2 +- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/elasticapm/contrib/django/handlers.py b/elasticapm/contrib/django/handlers.py index 0c97e888d..c980acc4f 100644 --- a/elasticapm/contrib/django/handlers.py +++ b/elasticapm/contrib/django/handlers.py @@ -47,11 +47,11 @@ class LoggingHandler(BaseLoggingHandler): def __init__(self, level=logging.NOTSET) -> None: warnings.warn( - "The LoggingHandler will be deprecated in v7.0 of the agent. " + "The LoggingHandler is deprecated and will be removed in v7.0 of the agent. " "Please use `log_ecs_reformatting` and ship the logs with Elastic " "Agent or Filebeat instead. " "https://www.elastic.co/guide/en/apm/agent/python/current/logs.html", - PendingDeprecationWarning, + DeprecationWarning, ) # skip initialization of BaseLoggingHandler logging.Handler.__init__(self, level=level) diff --git a/elasticapm/contrib/flask/__init__.py b/elasticapm/contrib/flask/__init__.py index e9ec3323e..fdb6906dd 100644 --- a/elasticapm/contrib/flask/__init__.py +++ b/elasticapm/contrib/flask/__init__.py @@ -87,7 +87,7 @@ def __init__(self, app=None, client=None, client_cls=Client, logging=False, **de if self.logging: warnings.warn( "Flask log shipping is deprecated. See the Flask docs for more info and alternatives.", - PendingDeprecationWarning, + DeprecationWarning, ) self.client = client or get_client() self.client_cls = client_cls diff --git a/elasticapm/contrib/opentracing/__init__.py b/elasticapm/contrib/opentracing/__init__.py index 8fbc99b19..71619ea20 100644 --- a/elasticapm/contrib/opentracing/__init__.py +++ b/elasticapm/contrib/opentracing/__init__.py @@ -36,8 +36,8 @@ warnings.warn( ( - "The OpenTracing bridge will be deprecated in the next major release. " + "The OpenTracing bridge is deprecated and will be removed in the next major release. " "Please migrate to the OpenTelemetry bridge." ), - PendingDeprecationWarning, + DeprecationWarning, ) diff --git a/elasticapm/handlers/logging.py b/elasticapm/handlers/logging.py index ed4db87ac..96718d2db 100644 --- a/elasticapm/handlers/logging.py +++ b/elasticapm/handlers/logging.py @@ -51,7 +51,7 @@ def __init__(self, *args, **kwargs) -> None: "the agent. Please use `log_ecs_reformatting` and ship the logs " "with Elastic Agent or Filebeat instead. " "https://www.elastic.co/guide/en/apm/agent/python/current/logs.html", - PendingDeprecationWarning, + DeprecationWarning, ) self.client = None if "client" in kwargs: @@ -66,12 +66,9 @@ def __init__(self, *args, **kwargs) -> None: if client_cls: self.client = client_cls(*args, **kwargs) else: - # In 6.0, this should raise a ValueError warnings.warn( - "LoggingHandler requires a Client instance. No Client was " - "received. This will result in an error starting in v6.0 " - "of the agent", - PendingDeprecationWarning, + "LoggingHandler requires a Client instance. No Client was received.", + DeprecationWarning, ) self.client = Client(*args, **kwargs) logging.Handler.__init__(self, level=kwargs.get("level", logging.NOTSET)) @@ -201,7 +198,7 @@ def __init__(self, name=""): "the agent. On Python 3.2+, by default we add a LogRecordFactory to " "your root logger automatically" "https://www.elastic.co/guide/en/apm/agent/python/current/logs.html", - PendingDeprecationWarning, + DeprecationWarning, ) def filter(self, record): diff --git a/tests/handlers/logging/logging_tests.py b/tests/handlers/logging/logging_tests.py index 8e23a0b69..8cc8fc4f1 100644 --- a/tests/handlers/logging/logging_tests.py +++ b/tests/handlers/logging/logging_tests.py @@ -380,7 +380,7 @@ def test_logging_handler_no_client(recwarn): while True: # If we never find our desired warning this will eventually throw an # AssertionError - w = recwarn.pop(PendingDeprecationWarning) + w = recwarn.pop(DeprecationWarning) if "LoggingHandler requires a Client instance" in w.message.args[0]: return True