Skip to content

Commit f78c49d

Browse files
ref: Remove SpanKwargs and TransactionKwargs
These classes were added so that `start_transaction`'s `kwargs` would be typed. Now that that function is deprecated, these classes are no longer needed. The types have also now diverged from the actual signature of `Span.__init__`, making their continued presence confusing
1 parent 43133b3 commit f78c49d

File tree

4 files changed

+4
-92
lines changed

4 files changed

+4
-92
lines changed

sentry_sdk/api.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
from typing import Union
3131
from typing import Generator
3232

33-
from typing_extensions import Unpack
34-
3533
from sentry_sdk.client import BaseClient
3634
from sentry_sdk._types import (
3735
Event,
@@ -42,7 +40,7 @@
4240
MeasurementUnit,
4341
LogLevelStr,
4442
)
45-
from sentry_sdk.tracing import Span, TransactionKwargs
43+
from sentry_sdk.tracing import Span
4644

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

259257
def start_transaction(
260258
transaction=None, # type: Optional[Span]
261-
**kwargs, # type: Unpack[TransactionKwargs]
259+
**kwargs, # type: Any
262260
):
263261
# type: (...) -> Span
264262
"""

sentry_sdk/integrations/opentelemetry/scope.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434

3535
if TYPE_CHECKING:
3636
from typing import Tuple, Optional, Generator, Dict, Any
37-
from typing_extensions import Unpack
38-
39-
from sentry_sdk.tracing import TransactionKwargs
4037

4138

4239
class PotelScope(Scope):
@@ -136,7 +133,7 @@ def _incoming_otel_span_context(self):
136133
return span_context
137134

138135
def start_transaction(self, **kwargs):
139-
# type: (Unpack[TransactionKwargs]) -> Span
136+
# type: (Any) -> Span
140137
"""
141138
.. deprecated:: 3.0.0
142139
This function is deprecated and will be removed in a future release.

sentry_sdk/scope.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@
5656
from typing import Union
5757
from typing import Self
5858

59-
from typing_extensions import Unpack
60-
6159
from sentry_sdk._types import (
6260
Breadcrumb,
6361
BreadcrumbHint,
@@ -70,8 +68,6 @@
7068
Type,
7169
)
7270

73-
from sentry_sdk.tracing import TransactionKwargs
74-
7571
import sentry_sdk
7672

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

912908
def start_transaction(self, **kwargs):
913-
# type: (Unpack[TransactionKwargs]) -> Union[NoOpSpan, Span]
909+
# type: (Any) -> Union[NoOpSpan, Span]
914910
"""
915911
.. deprecated:: 3.0.0
916912
This function is deprecated and will be removed in a future release.

sentry_sdk/tracing.py

-79
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
from typing import Union
3939
from typing import TypeVar
4040

41-
from typing_extensions import TypedDict
42-
4341
P = ParamSpec("P")
4442
R = TypeVar("R")
4543

@@ -50,83 +48,6 @@
5048

5149
from sentry_sdk.tracing_utils import Baggage
5250

53-
class SpanKwargs(TypedDict, total=False):
54-
trace_id: str
55-
"""
56-
The trace ID of the root span. If this new span is to be the root span,
57-
omit this parameter, and a new trace ID will be generated.
58-
"""
59-
60-
span_id: str
61-
"""The span ID of this span. If omitted, a new span ID will be generated."""
62-
63-
parent_span_id: str
64-
"""The span ID of the parent span, if applicable."""
65-
66-
same_process_as_parent: bool
67-
"""Whether this span is in the same process as the parent span."""
68-
69-
sampled: bool
70-
"""
71-
Whether the span should be sampled. Overrides the default sampling decision
72-
for this span when provided.
73-
"""
74-
75-
op: str
76-
"""
77-
The span's operation. A list of recommended values is available here:
78-
https://develop.sentry.dev/sdk/performance/span-operations/
79-
"""
80-
81-
description: str
82-
"""A description of what operation is being performed within the span. This argument is DEPRECATED. Please use the `name` parameter, instead."""
83-
84-
status: str
85-
"""The span's status. Possible values are listed at https://develop.sentry.dev/sdk/event-payloads/span/"""
86-
87-
containing_transaction: Optional["Span"]
88-
"""The transaction that this span belongs to."""
89-
90-
start_timestamp: Optional[Union[datetime, float]]
91-
"""
92-
The timestamp when the span started. If omitted, the current time
93-
will be used.
94-
"""
95-
96-
scope: "sentry_sdk.Scope"
97-
"""The scope to use for this span. If not provided, we use the current scope."""
98-
99-
origin: Optional[str]
100-
"""
101-
The origin of the span.
102-
See https://develop.sentry.dev/sdk/performance/trace-origin/
103-
Default "manual".
104-
"""
105-
106-
name: str
107-
"""A string describing what operation is being performed within the span/transaction."""
108-
109-
class TransactionKwargs(SpanKwargs, total=False):
110-
source: str
111-
"""
112-
A string describing the source of the transaction name. This will be used to determine the transaction's type.
113-
See https://develop.sentry.dev/sdk/event-payloads/transaction/#transaction-annotations for more information.
114-
Default "custom".
115-
"""
116-
117-
parent_sampled: bool
118-
"""Whether the parent transaction was sampled. If True this transaction will be kept, if False it will be discarded."""
119-
120-
baggage: "Baggage"
121-
"""The W3C baggage header value. (see https://www.w3.org/TR/baggage/)"""
122-
123-
ProfileContext = TypedDict(
124-
"ProfileContext",
125-
{
126-
"profiler_id": str,
127-
},
128-
)
129-
13051
BAGGAGE_HEADER_NAME = "baggage"
13152
SENTRY_TRACE_HEADER_NAME = "sentry-trace"
13253

0 commit comments

Comments
 (0)