11import inspect
22from typing import TYPE_CHECKING
33
4- from sentry_sdk import Client , tracing_utils
4+ from sentry_sdk import Client , traces
55from sentry_sdk ._init_implementation import init
66from sentry_sdk .crons import monitor
77from sentry_sdk .scope import Scope , isolation_scope , new_scope
8- from sentry_sdk .tracing import NoOpSpan , Transaction , trace
8+ from sentry_sdk .traces import trace
99
1010if TYPE_CHECKING :
1111 from collections .abc import Mapping
1919 overload ,
2020 )
2121
22- from typing_extensions import Unpack
23-
2422 from sentry_sdk ._types import (
2523 Breadcrumb ,
2624 BreadcrumbHint ,
2725 Event ,
2826 ExcInfo ,
2927 Hint ,
3028 LogLevelStr ,
31- SamplingContext ,
3229 )
3330 from sentry_sdk .client import BaseClient
34- from sentry_sdk .tracing import Span , TransactionKwargs
31+ from sentry_sdk .traces import StreamedSpan
3532
3633 T = TypeVar ("T" )
3734 F = TypeVar ("F" , bound = Callable [..., Any ])
@@ -50,6 +47,7 @@ def overload(x: "T") -> "T":
5047 "capture_exception" ,
5148 "capture_message" ,
5249 "continue_trace" ,
50+ "new_trace" ,
5351 "flush" ,
5452 "flush_async" ,
5553 "get_baggage" ,
@@ -73,7 +71,6 @@ def overload(x: "T") -> "T":
7371 "set_tags" ,
7472 "set_user" ,
7573 "start_span" ,
76- "start_transaction" ,
7774 "trace" ,
7875 "monitor" ,
7976 "start_session" ,
@@ -273,59 +270,15 @@ async def flush_async(
273270
274271
275272@scopemethod
276- def start_span (
277- ** kwargs : "Any" ,
278- ) -> "Span" :
279- return get_current_scope ().start_span (** kwargs )
280-
281-
282- @scopemethod
283- def start_transaction (
284- transaction : "Optional[Transaction]" = None ,
285- custom_sampling_context : "Optional[SamplingContext]" = None ,
286- ** kwargs : "Unpack[TransactionKwargs]" ,
287- ) -> "Union[Transaction, NoOpSpan]" :
288- """
289- Start and return a transaction on the current scope.
290-
291- Start an existing transaction if given, otherwise create and start a new
292- transaction with kwargs.
293-
294- This is the entry point to manual tracing instrumentation.
295-
296- A tree structure can be built by adding child spans to the transaction,
297- and child spans to other spans. To start a new child span within the
298- transaction or any span, call the respective `.start_child()` method.
299-
300- Every child span must be finished before the transaction is finished,
301- otherwise the unfinished spans are discarded.
273+ def start_span (** kwargs : "Any" ) -> "StreamedSpan" :
274+ return traces .start_span (** kwargs )
302275
303- When used as context managers, spans and transactions are automatically
304- finished at the end of the `with` block. If not using context managers,
305- call the `.finish()` method.
306276
307- When the transaction is finished, it will be sent to Sentry with all its
308- finished child spans.
309-
310- :param transaction: The transaction to start. If omitted, we create and
311- start a new transaction.
312- :param custom_sampling_context: The transaction's custom sampling context.
313- :param kwargs: Optional keyword arguments to be passed to the Transaction
314- constructor. See :py:class:`sentry_sdk.tracing.Transaction` for
315- available arguments.
316- """
317- return get_current_scope ().start_transaction (
318- transaction , custom_sampling_context , ** kwargs
319- )
320-
321-
322- def get_current_span (
323- scope : "Optional[Scope]" = None ,
324- ) -> "Optional[Span]" :
277+ def get_current_span (scope : "Optional[Scope]" = None ) -> "Optional[StreamedSpan]" :
325278 """
326279 Returns the currently active span if there is one running, otherwise `None`
327280 """
328- return tracing_utils .get_current_span (scope )
281+ return traces .get_current_span (scope )
329282
330283
331284def get_traceparent () -> "Optional[str]" :
@@ -346,19 +299,18 @@ def get_baggage() -> "Optional[str]":
346299 return None
347300
348301
349- def continue_trace (
350- environ_or_headers : "Dict[str, Any]" ,
351- op : "Optional[str]" = None ,
352- name : "Optional[str]" = None ,
353- source : "Optional[str]" = None ,
354- origin : str = "manual" ,
355- ) -> "Transaction" :
302+ def continue_trace (incoming : "Dict[str, Any]" ) -> None :
356303 """
357- Sets the propagation context from environment or headers and returns a transaction .
304+ Sets the propagation context from environment or headers.
358305 """
359- return get_isolation_scope ().continue_trace (
360- environ_or_headers , op , name , source , origin
361- )
306+ return traces .continue_trace (incoming )
307+
308+
309+ def new_trace () -> None :
310+ """
311+ Resets the propagation context, forcing a new trace.
312+ """
313+ return traces .new_trace ()
362314
363315
364316@scopemethod
0 commit comments