Skip to content

Commit cb2c70f

Browse files
authored
Remove deprecated code (getsentry#2666)
* remove deprecated client options * remove .install() * remove new_span
1 parent 2452113 commit cb2c70f

5 files changed

Lines changed: 5 additions & 97 deletions

File tree

MIGRATION_GUIDE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
- Removed support for Flask 0.\*.
2121
- `sentry_sdk._functools` was removed.
2222
- A number of compatibility utilities were removed from `sentry_sdk._compat`: the constants `PY2` and `PY33`; the functions `datetime_utcnow`, `utc_from_timestamp`, `implements_str`, `contextmanager`; and the aliases `text_type`, `string_types`, `number_types`, `int_types`, `iteritems`, `binary_sequence_types`.
23+
- The deprecated `with_locals` configuration option was removed. Use `include_local_variables` instead. See https://docs.sentry.io/platforms/python/configuration/options/#include-local-variables.
24+
- The deprecated `request_bodies` configuration option was removed. Use `max_request_body_size`. See https://docs.sentry.io/platforms/python/configuration/options/#max-request-body-size.
2325
- Removed `tracing_utils_py2.py`. The `start_child_span_decorator` is now in `sentry_sdk.tracing_utils`.
26+
- Removed support for the `install` method for custom integrations. Please use `setup_once` instead.
27+
- Removed `sentry_sdk.tracing.Span.new_span`. Use `sentry_sdk.tracing.Span.start_child` instead.
28+
- Removed `sentry_sdk.tracing.Transaction.new_span`. Use `sentry_sdk.tracing.Transaction.start_child` instead.
2429

2530
## Deprecated

sentry_sdk/client.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,6 @@ def _get_options(*args, **kwargs):
8080

8181
for key, value in options.items():
8282
if key not in rv:
83-
# Option "with_locals" was renamed to "include_local_variables"
84-
if key == "with_locals":
85-
msg = (
86-
"Deprecated: The option 'with_locals' was renamed to 'include_local_variables'. "
87-
"Please use 'include_local_variables'. The option 'with_locals' will be removed in the future."
88-
)
89-
logger.warning(msg)
90-
rv["include_local_variables"] = value
91-
continue
92-
93-
# Option "request_bodies" was renamed to "max_request_body_size"
94-
if key == "request_bodies":
95-
msg = (
96-
"Deprecated: The option 'request_bodies' was renamed to 'max_request_body_size'. "
97-
"Please use 'max_request_body_size'. The option 'request_bodies' will be removed in the future."
98-
)
99-
logger.warning(msg)
100-
rv["max_request_body_size"] = value
101-
continue
102-
10383
raise TypeError("Unknown option %r" % (key,))
10484

10585
rv[key] = value

sentry_sdk/integrations/__init__.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,6 @@ def setup_integrations(
143143
)
144144
try:
145145
type(integration).setup_once()
146-
except NotImplementedError:
147-
if getattr(integration, "install", None) is not None:
148-
logger.warning(
149-
"Integration %s: The install method is "
150-
"deprecated. Use `setup_once`.",
151-
identifier,
152-
)
153-
integration.install() # type: ignore
154-
else:
155-
raise
156146
except DidNotEnable as e:
157147
if identifier not in used_as_default_integration:
158148
raise

sentry_sdk/tracing.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,6 @@ def start_child(self, instrumenter=INSTRUMENTER.SENTRY, **kwargs):
263263

264264
return child
265265

266-
def new_span(self, **kwargs):
267-
# type: (**Any) -> Span
268-
"""DEPRECATED: use :py:meth:`sentry_sdk.tracing.Span.start_child` instead."""
269-
logger.warning(
270-
"Deprecated: use Span.start_child instead of Span.new_span. This will be removed in the future."
271-
)
272-
return self.start_child(**kwargs)
273-
274266
@classmethod
275267
def continue_from_environ(
276268
cls,
@@ -917,10 +909,6 @@ def start_child(self, instrumenter=INSTRUMENTER.SENTRY, **kwargs):
917909
# type: (str, **Any) -> NoOpSpan
918910
return NoOpSpan()
919911

920-
def new_span(self, **kwargs):
921-
# type: (**Any) -> NoOpSpan
922-
return self.start_child(**kwargs)
923-
924912
def to_traceparent(self):
925913
# type: () -> str
926914
return ""

tests/test_client.py

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
)
2323
from sentry_sdk.integrations.executing import ExecutingIntegration
2424
from sentry_sdk.transport import Transport
25-
from sentry_sdk.utils import logger
2625
from sentry_sdk.serializer import MAX_DATABAG_BREADTH
2726
from sentry_sdk.consts import DEFAULT_MAX_BREADCRUMBS, DEFAULT_MAX_VALUE_LENGTH
2827
from sentry_sdk._types import TYPE_CHECKING
@@ -367,60 +366,6 @@ def e(exc):
367366
assert mock_capture_internal_exception.call_args[0][0][0] == EventCapturedError
368367

369368

370-
def test_with_locals_deprecation_enabled(sentry_init):
371-
with mock.patch.object(logger, "warning", mock.Mock()) as fake_warning:
372-
sentry_init(with_locals=True)
373-
374-
client = Hub.current.client
375-
assert "with_locals" not in client.options
376-
assert "include_local_variables" in client.options
377-
assert client.options["include_local_variables"]
378-
379-
fake_warning.assert_called_once_with(
380-
"Deprecated: The option 'with_locals' was renamed to 'include_local_variables'. Please use 'include_local_variables'. The option 'with_locals' will be removed in the future."
381-
)
382-
383-
384-
def test_with_locals_deprecation_disabled(sentry_init):
385-
with mock.patch.object(logger, "warning", mock.Mock()) as fake_warning:
386-
sentry_init(with_locals=False)
387-
388-
client = Hub.current.client
389-
assert "with_locals" not in client.options
390-
assert "include_local_variables" in client.options
391-
assert not client.options["include_local_variables"]
392-
393-
fake_warning.assert_called_once_with(
394-
"Deprecated: The option 'with_locals' was renamed to 'include_local_variables'. Please use 'include_local_variables'. The option 'with_locals' will be removed in the future."
395-
)
396-
397-
398-
def test_include_local_variables_deprecation(sentry_init):
399-
with mock.patch.object(logger, "warning", mock.Mock()) as fake_warning:
400-
sentry_init(include_local_variables=False)
401-
402-
client = Hub.current.client
403-
assert "with_locals" not in client.options
404-
assert "include_local_variables" in client.options
405-
assert not client.options["include_local_variables"]
406-
407-
fake_warning.assert_not_called()
408-
409-
410-
def test_request_bodies_deprecation(sentry_init):
411-
with mock.patch.object(logger, "warning", mock.Mock()) as fake_warning:
412-
sentry_init(request_bodies="small")
413-
414-
client = Hub.current.client
415-
assert "request_bodies" not in client.options
416-
assert "max_request_body_size" in client.options
417-
assert client.options["max_request_body_size"] == "small"
418-
419-
fake_warning.assert_called_once_with(
420-
"Deprecated: The option 'request_bodies' was renamed to 'max_request_body_size'. Please use 'max_request_body_size'. The option 'request_bodies' will be removed in the future."
421-
)
422-
423-
424369
def test_include_local_variables_enabled(sentry_init, capture_events):
425370
sentry_init(include_local_variables=True)
426371
events = capture_events()

0 commit comments

Comments
 (0)