Skip to content

Commit

Permalink
Removed deprecated parameter from start_span()
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker committed Feb 21, 2024
1 parent 7e17064 commit dbf3694
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 39 deletions.
15 changes: 7 additions & 8 deletions sentry_sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def capture_event(
event, # type: Event
hint=None, # type: Optional[Hint]
scope=None, # type: Optional[Any]
**scope_kwargs # type: Any
**scope_kwargs, # type: Any
):
# type: (...) -> Optional[str]
return Scope.get_current_scope().capture_event(
Expand All @@ -121,7 +121,7 @@ def capture_message(
message, # type: str
level=None, # type: Optional[str]
scope=None, # type: Optional[Any]
**scope_kwargs # type: Any
**scope_kwargs, # type: Any
):
# type: (...) -> Optional[str]
return Scope.get_current_scope().capture_message(
Expand All @@ -133,7 +133,7 @@ def capture_message(
def capture_exception(
error=None, # type: Optional[Union[BaseException, ExcInfo]]
scope=None, # type: Optional[Any]
**scope_kwargs # type: Any
**scope_kwargs, # type: Any
):
# type: (...) -> Optional[str]
return Scope.get_current_scope().capture_exception(
Expand All @@ -145,7 +145,7 @@ def capture_exception(
def add_breadcrumb(
crumb=None, # type: Optional[Breadcrumb]
hint=None, # type: Optional[BreadcrumbHint]
**kwargs # type: Any
**kwargs, # type: Any
):
# type: (...) -> None
return Scope.get_isolation_scope().add_breadcrumb(crumb, hint, **kwargs)
Expand Down Expand Up @@ -283,17 +283,16 @@ def flush(

@scopemethod
def start_span(
span=None, # type: Optional[Span]
**kwargs # type: Any
**kwargs, # type: Any
):
# type: (...) -> Span
return Scope.get_current_scope().start_span(span=span, **kwargs)
return Scope.get_current_scope().start_span(**kwargs)


@scopemethod
def start_transaction(
transaction=None, # type: Optional[Transaction]
**kwargs # type: Any
**kwargs, # type: Any
):
# type: (...) -> Union[Transaction, NoOpSpan]
return Scope.get_current_scope().start_transaction(transaction, **kwargs)
Expand Down
6 changes: 3 additions & 3 deletions sentry_sdk/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ def add_breadcrumb(self, crumb=None, hint=None, **kwargs):
"""
Scope.get_isolation_scope().add_breadcrumb(crumb, hint, **kwargs)

def start_span(self, span=None, instrumenter=INSTRUMENTER.SENTRY, **kwargs):
# type: (Optional[Span], str, Any) -> Span
def start_span(self, instrumenter=INSTRUMENTER.SENTRY, **kwargs):
# type: (str, Any) -> Span
"""
.. deprecated:: 2.0.0
This function is deprecated and will be removed in a future release.
Expand All @@ -460,7 +460,7 @@ def start_span(self, span=None, instrumenter=INSTRUMENTER.SENTRY, **kwargs):
For supported `**kwargs` see :py:class:`sentry_sdk.tracing.Span`.
"""
scope = Scope.get_isolation_scope()
return scope.start_span(span=span, instrumenter=instrumenter, **kwargs)
return scope.start_span(instrumenter=instrumenter, **kwargs)

def start_transaction(
self, transaction=None, instrumenter=INSTRUMENTER.SENTRY, **kwargs
Expand Down
30 changes: 2 additions & 28 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,8 +937,8 @@ def start_transaction(

return transaction

def start_span(self, span=None, instrumenter=INSTRUMENTER.SENTRY, **kwargs):
# type: (Optional[Span], str, Any) -> Span
def start_span(self, instrumenter=INSTRUMENTER.SENTRY, **kwargs):
# type: (str, Any) -> Span
"""
Start a span whose parent is the currently active span or transaction, if any.
Expand All @@ -963,32 +963,6 @@ def start_span(self, span=None, instrumenter=INSTRUMENTER.SENTRY, **kwargs):
if instrumenter != configuration_instrumenter:
return NoOpSpan()

# THIS BLOCK IS DEPRECATED
# TODO: consider removing this in a future release.
# This is for backwards compatibility with releases before
# start_transaction existed, to allow for a smoother transition.
if isinstance(span, Transaction) or "transaction" in kwargs:
deprecation_msg = (
"Deprecated: use start_transaction to start transactions and "
"Transaction.start_child to start spans."
)

if isinstance(span, Transaction):
logger.warning(deprecation_msg)
return self.start_transaction(span, **kwargs)

if "transaction" in kwargs:
logger.warning(deprecation_msg)
name = kwargs.pop("transaction")
return self.start_transaction(name=name, **kwargs)

# THIS BLOCK IS DEPRECATED
# We do not pass a span into start_span in our code base, so I deprecate this.
if span is not None:
deprecation_msg = "Deprecated: passing a span into `start_span` is deprecated and will be removed in the future."
logger.warning(deprecation_msg)
return span

scope = Scope.get_current_scope()
span = scope.span

Expand Down

0 comments on commit dbf3694

Please sign in to comment.