Skip to content

Commit cf5a94f

Browse files
ref: Remove deprecated Transaction creation method (#2917)
This has been deprecated for 4 years, so I suppose we can remove it now in 2.0. Removing the __new__ method also fixes our API docs for the Span and Transaction constructors. Partially addresses getsentry/sentry-docs#5082
1 parent 46087c3 commit cf5a94f

File tree

2 files changed

+1
-25
lines changed

2 files changed

+1
-25
lines changed

MIGRATION_GUIDE.md

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Looking to upgrade from Sentry SDK 1.x to 2.x? Here's a comprehensive list of wh
7171
- Removed support for the `install` method for custom integrations. Please use `setup_once` instead.
7272
- Removed `sentry_sdk.tracing.Span.new_span`. Use `sentry_sdk.tracing.Span.start_child` instead.
7373
- Removed `sentry_sdk.tracing.Transaction.new_span`. Use `sentry_sdk.tracing.Transaction.start_child` instead.
74+
- Removed support for creating transactions via `sentry_sdk.tracing.Span(transaction=...)`. To create a transaction, please use `sentry_sdk.tracing.Transaction(name=...)`.
7475
- Removed `sentry_sdk.utils.Auth.store_api_url`.
7576
- `sentry_sdk.utils.Auth.get_api_url`'s now accepts a `sentry_sdk.consts.EndpointType` enum instead of a string as its only parameter. We recommend omitting this argument when calling the function, since the parameter's default value is the only possible `sentry_sdk.consts.EndpointType` value. The parameter exists for future compatibility.
7677
- Removed `tracing_utils_py2.py`. The `start_child_span_decorator` is now in `sentry_sdk.tracing_utils`.

sentry_sdk/tracing.py

-25
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class SpanKwargs(TypedDict, total=False):
4040
description: str
4141
# hub: Optional[sentry_sdk.Hub] is deprecated, and therefore omitted here!
4242
status: str
43-
# transaction: str is deprecated, and therefore omitted here!
4443
containing_transaction: Optional["Transaction"]
4544
start_timestamp: Optional[Union[datetime, float]]
4645
scope: "sentry_sdk.Scope"
@@ -132,20 +131,6 @@ class Span:
132131
"scope",
133132
)
134133

135-
def __new__(cls, **kwargs):
136-
# type: (**Any) -> Any
137-
"""
138-
Backwards-compatible implementation of Span and Transaction
139-
creation.
140-
"""
141-
142-
# TODO: consider removing this in a future release.
143-
# This is for backwards compatibility with releases before Transaction
144-
# existed, to allow for a smoother transition.
145-
if "transaction" in kwargs:
146-
return object.__new__(Transaction)
147-
return object.__new__(cls)
148-
149134
def __init__(
150135
self,
151136
trace_id=None, # type: Optional[str]
@@ -157,7 +142,6 @@ def __init__(
157142
description=None, # type: Optional[str]
158143
hub=None, # type: Optional[sentry_sdk.Hub] # deprecated
159144
status=None, # type: Optional[str]
160-
transaction=None, # type: Optional[str] # deprecated
161145
containing_transaction=None, # type: Optional[Transaction]
162146
start_timestamp=None, # type: Optional[Union[datetime, float]]
163147
scope=None, # type: Optional[sentry_sdk.Scope]
@@ -598,15 +582,6 @@ def __init__(
598582
See https://develop.sentry.dev/sdk/event-payloads/transaction/#transaction-annotations
599583
for more information. Default "custom".
600584
"""
601-
# TODO: consider removing this in a future release.
602-
# This is for backwards compatibility with releases before Transaction
603-
# existed, to allow for a smoother transition.
604-
if not name and "transaction" in kwargs:
605-
logger.warning(
606-
"Deprecated: use Transaction(name=...) to create transactions "
607-
"instead of Span(transaction=...)."
608-
)
609-
name = kwargs.pop("transaction") # type: ignore
610585

611586
super().__init__(**kwargs)
612587

0 commit comments

Comments
 (0)