File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,3 +66,7 @@ Managing Scope (advanced)
6666.. autofunction :: sentry_sdk.api.push_scope
6767
6868.. autofunction :: sentry_sdk.api.new_scope
69+ .. autofunction :: sentry_sdk.api.isolation_scope
70+
71+ .. autofunction :: sentry_sdk.api.get_current_scope
72+ .. autofunction :: sentry_sdk.api.get_isolation_scope
Original file line number Diff line number Diff line change @@ -8,5 +8,6 @@ visit the `GitHub repository <https://github.com/getsentry/sentry-python>`_.
88
99.. toctree ::
1010 api
11+ tracing
1112 integrations
1213 apidocs
Original file line number Diff line number Diff line change 1+ =======
2+ Tracing
3+ =======
4+
5+ With Performance Monitoring, Sentry tracks your software's performance, measuring variables such as throughput and latency.
6+
7+ Manual Instrumentation
8+ =====================
9+
10+ You can manually start transactions and spans to trace custom operations in your application.
11+
12+ Transactions
13+ ------------
14+ A transaction represents a single instance of a service being called. It forms the root of a trace tree.
15+
16+ .. code-block :: python
17+
18+ import sentry_sdk
19+
20+ # Start a transaction as a context manager
21+ with sentry_sdk.start_transaction(name = " process-order" ):
22+ # Your application logic here
23+ pass
24+
25+ Spans
26+ -----
27+ Spans represent individual units of work within a transaction, such as a database query or an API call.
28+
29+ .. code-block :: python
30+
31+ import sentry_sdk
32+
33+ # Start a child span under the current transaction
34+ with sentry_sdk.start_child_span(op = " db.query" , name = " SELECT * FROM users" ):
35+ # Your operation here
36+ pass
37+
38+
39+ Managing Context with Scopes
40+ ============================
41+
42+ Sentry use **Scopes ** to manage execution context and event enrichment. In SDK 2.x, top-level APIs replace the deprecated Hub model.
43+
44+ Isolation Scope
45+ ---------------
46+ The `isolation_scope ` should be used for isolating data that belongs to a single request or job lifecycle. It propagates data across child scopes.
47+
48+ .. code-block :: python
49+
50+ import sentry_sdk
51+
52+ with sentry_sdk.isolation_scope() as scope:
53+ scope.set_tag(" user_type" , " admin" )
54+ # Operations triggered here will include the tag
55+
56+ New Scope
57+ ---------
58+ The `new_scope ` forks the current scope for local, short-lived modifications.
59+
60+ .. code-block :: python
61+
62+ import sentry_sdk
63+
64+ with sentry_sdk.new_scope() as scope:
65+ scope.set_extra(" temp_debug_data" , 123 )
66+ # Changes are discarded when existing the block
You can’t perform that action at this time.
0 commit comments