Skip to content

Commit 59074fd

Browse files
committed
Switch all deprecation warnings to the warnings module
1 parent d145612 commit 59074fd

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

sentry_sdk/integrations/threading.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22
from functools import wraps
33
from threading import Thread, current_thread
4+
import warnings
45

56
import sentry_sdk
67
from sentry_sdk.integrations import Integration

sentry_sdk/profiler/transaction_profiler.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,12 @@ def has_profiling_enabled(options):
127127

128128
profiles_sample_rate = options["_experiments"].get("profiles_sample_rate")
129129
if profiles_sample_rate is not None:
130-
logger.warning(
131-
"_experiments['profiles_sample_rate'] is deprecated. "
132-
"Please use the non-experimental profiles_sample_rate option "
133-
"directly."
130+
warnings.warn(
131+
"_experiments['profiles_sample_rate'] is deprecated. Please use the non-experimental profiles_sample_rate option directly.",
132+
stacklevel=2,
133+
category=DeprecationWarning,
134134
)
135+
135136
if profiles_sample_rate > 0:
136137
return True
137138

@@ -162,10 +163,12 @@ def setup_profiler(options):
162163
else:
163164
profiler_mode = options.get("_experiments", {}).get("profiler_mode")
164165
if profiler_mode is not None:
165-
logger.warning(
166-
"_experiments['profiler_mode'] is deprecated. Please use the "
167-
"non-experimental profiler_mode option directly."
166+
warnings.warn(
167+
"_experiments['profiler_mode'] is deprecated. Please use the non-experimental profiler_mode option directly.",
168+
stacklevel=2,
169+
category=DeprecationWarning,
168170
)
171+
169172
profiler_mode = profiler_mode or default_profiler_mode
170173

171174
if (

sentry_sdk/scope.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,10 @@ def trace_propagation_meta(self, *args, **kwargs):
563563
"""
564564
span = kwargs.pop("span", None)
565565
if span is not None:
566-
logger.warning(
567-
"The parameter `span` in trace_propagation_meta() is deprecated and will be removed in the future."
566+
warnings.warn(
567+
"The parameter `span` in trace_propagation_meta() is deprecated and will be removed in the future.",
568+
stacklevel=2,
569+
category=DeprecationWarning,
568570
)
569571

570572
meta = ""
@@ -734,10 +736,12 @@ def transaction(self, value):
734736
# Without breaking version compatibility, we could make the setter set a
735737
# transaction name or transaction (self._span) depending on the type of
736738
# the value argument.
737-
738-
logger.warning(
739-
"Assigning to scope.transaction directly is deprecated: use scope.set_transaction_name() instead."
739+
warnings.warn(
740+
"Assigning to scope.transaction directly is deprecated: use scope.set_transaction_name() instead.",
741+
stacklevel=2,
742+
category=DeprecationWarning,
740743
)
744+
741745
self._transaction = value
742746
if self._span and self._span.containing_transaction:
743747
self._span.containing_transaction.name = value

0 commit comments

Comments
 (0)