Skip to content

Commit

Permalink
Promote some PendingDeprecationWarning to DeprecationWarning (#2076)
Browse files Browse the repository at this point in the history
Promote the removal of opentracing integration and the removal of
logging handling to DeprecationWarnings.

Refs #2029
  • Loading branch information
xrmx committed Jul 9, 2024
1 parent c5b6e15 commit ded855b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions elasticapm/contrib/django/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion elasticapm/contrib/flask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions elasticapm/contrib/opentracing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
11 changes: 4 additions & 7 deletions elasticapm/handlers/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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))
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/logging/logging_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ded855b

Please sign in to comment.