Skip to content

ref: Remove SpanKwargs and TransactionKwargs #4254

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 1 commit into from
Apr 9, 2025
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
6 changes: 2 additions & 4 deletions sentry_sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
from typing import Union
from typing import Generator

from typing_extensions import Unpack

from sentry_sdk.client import BaseClient
from sentry_sdk._types import (
Event,
Expand All @@ -42,7 +40,7 @@
MeasurementUnit,
LogLevelStr,
)
from sentry_sdk.tracing import Span, TransactionKwargs
from sentry_sdk.tracing import Span

T = TypeVar("T")
F = TypeVar("F", bound=Callable[..., Any])
Expand Down Expand Up @@ -258,7 +256,7 @@ def start_span(**kwargs):

def start_transaction(
transaction=None, # type: Optional[Span]
**kwargs, # type: Unpack[TransactionKwargs]
**kwargs, # type: Any
):
# type: (...) -> Span
"""
Expand Down
5 changes: 1 addition & 4 deletions sentry_sdk/integrations/opentelemetry/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@

if TYPE_CHECKING:
from typing import Tuple, Optional, Generator, Dict, Any
from typing_extensions import Unpack

from sentry_sdk.tracing import TransactionKwargs


class PotelScope(Scope):
Expand Down Expand Up @@ -136,7 +133,7 @@ def _incoming_otel_span_context(self):
return span_context

def start_transaction(self, **kwargs):
# type: (Unpack[TransactionKwargs]) -> Span
# type: (Any) -> Span
"""
.. deprecated:: 3.0.0
This function is deprecated and will be removed in a future release.
Expand Down
6 changes: 1 addition & 5 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
from typing import Union
from typing import Self

from typing_extensions import Unpack

from sentry_sdk._types import (
Breadcrumb,
BreadcrumbHint,
Expand All @@ -70,8 +68,6 @@
Type,
)

from sentry_sdk.tracing import TransactionKwargs

import sentry_sdk

P = ParamSpec("P")
Expand Down Expand Up @@ -910,7 +906,7 @@ def add_breadcrumb(self, crumb=None, hint=None, **kwargs):
self._n_breadcrumbs_truncated += 1

def start_transaction(self, **kwargs):
# type: (Unpack[TransactionKwargs]) -> Union[NoOpSpan, Span]
# type: (Any) -> Union[NoOpSpan, Span]
"""
.. deprecated:: 3.0.0
This function is deprecated and will be removed in a future release.
Expand Down
79 changes: 0 additions & 79 deletions sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
from typing import Union
from typing import TypeVar

from typing_extensions import TypedDict

P = ParamSpec("P")
R = TypeVar("R")

Expand All @@ -50,83 +48,6 @@

from sentry_sdk.tracing_utils import Baggage

class SpanKwargs(TypedDict, total=False):
trace_id: str
"""
The trace ID of the root span. If this new span is to be the root span,
omit this parameter, and a new trace ID will be generated.
"""

span_id: str
"""The span ID of this span. If omitted, a new span ID will be generated."""

parent_span_id: str
"""The span ID of the parent span, if applicable."""

same_process_as_parent: bool
"""Whether this span is in the same process as the parent span."""

sampled: bool
"""
Whether the span should be sampled. Overrides the default sampling decision
for this span when provided.
"""

op: str
"""
The span's operation. A list of recommended values is available here:
https://develop.sentry.dev/sdk/performance/span-operations/
"""

description: str
"""A description of what operation is being performed within the span. This argument is DEPRECATED. Please use the `name` parameter, instead."""

status: str
"""The span's status. Possible values are listed at https://develop.sentry.dev/sdk/event-payloads/span/"""

containing_transaction: Optional["Span"]
"""The transaction that this span belongs to."""

start_timestamp: Optional[Union[datetime, float]]
"""
The timestamp when the span started. If omitted, the current time
will be used.
"""

scope: "sentry_sdk.Scope"
"""The scope to use for this span. If not provided, we use the current scope."""

origin: Optional[str]
"""
The origin of the span.
See https://develop.sentry.dev/sdk/performance/trace-origin/
Default "manual".
"""

name: str
"""A string describing what operation is being performed within the span/transaction."""

class TransactionKwargs(SpanKwargs, total=False):
source: str
"""
A string describing the source of the transaction name. This will be used to determine the transaction's type.
See https://develop.sentry.dev/sdk/event-payloads/transaction/#transaction-annotations for more information.
Default "custom".
"""

parent_sampled: bool
"""Whether the parent transaction was sampled. If True this transaction will be kept, if False it will be discarded."""

baggage: "Baggage"
"""The W3C baggage header value. (see https://www.w3.org/TR/baggage/)"""

ProfileContext = TypedDict(
"ProfileContext",
{
"profiler_id": str,
},
)

BAGGAGE_HEADER_NAME = "baggage"
SENTRY_TRACE_HEADER_NAME = "sentry-trace"

Expand Down
Loading