Skip to content

ref: Remove deprecated Transaction creation method #2917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Looking to upgrade from Sentry SDK 1.x to 2.x? Here's a comprehensive list of wh
- Removed support for the `install` method for custom integrations. Please use `setup_once` instead.
- Removed `sentry_sdk.tracing.Span.new_span`. Use `sentry_sdk.tracing.Span.start_child` instead.
- Removed `sentry_sdk.tracing.Transaction.new_span`. Use `sentry_sdk.tracing.Transaction.start_child` instead.
- Removed support for creating transactions via `sentry_sdk.tracing.Span(transaction=...)`. To create a transaction, please use `sentry_sdk.tracing.Transaction(name=...)`.
- Removed `sentry_sdk.utils.Auth.store_api_url`.
- `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.
- Removed `tracing_utils_py2.py`. The `start_child_span_decorator` is now in `sentry_sdk.tracing_utils`.
Expand Down
25 changes: 0 additions & 25 deletions sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class SpanKwargs(TypedDict, total=False):
description: str
# hub: Optional[sentry_sdk.Hub] is deprecated, and therefore omitted here!
status: str
# transaction: str is deprecated, and therefore omitted here!
containing_transaction: Optional["Transaction"]
start_timestamp: Optional[Union[datetime, float]]
scope: "sentry_sdk.Scope"
Expand Down Expand Up @@ -132,20 +131,6 @@ class Span:
"scope",
)

def __new__(cls, **kwargs):
# type: (**Any) -> Any
"""
Backwards-compatible implementation of Span and Transaction
creation.
"""

# TODO: consider removing this in a future release.
# This is for backwards compatibility with releases before Transaction
# existed, to allow for a smoother transition.
if "transaction" in kwargs:
return object.__new__(Transaction)
return object.__new__(cls)

def __init__(
self,
trace_id=None, # type: Optional[str]
Expand All @@ -157,7 +142,6 @@ def __init__(
description=None, # type: Optional[str]
hub=None, # type: Optional[sentry_sdk.Hub] # deprecated
status=None, # type: Optional[str]
transaction=None, # type: Optional[str] # deprecated
containing_transaction=None, # type: Optional[Transaction]
start_timestamp=None, # type: Optional[Union[datetime, float]]
scope=None, # type: Optional[sentry_sdk.Scope]
Expand Down Expand Up @@ -598,15 +582,6 @@ def __init__(
See https://develop.sentry.dev/sdk/event-payloads/transaction/#transaction-annotations
for more information. Default "custom".
"""
# TODO: consider removing this in a future release.
# This is for backwards compatibility with releases before Transaction
# existed, to allow for a smoother transition.
if not name and "transaction" in kwargs:
logger.warning(
"Deprecated: use Transaction(name=...) to create transactions "
"instead of Span(transaction=...)."
)
name = kwargs.pop("transaction") # type: ignore

super().__init__(**kwargs)

Expand Down