You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MIGRATION_GUIDE.md
+26-4Lines changed: 26 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
# Sentry SDK 2.0 Migration Guide
2
2
3
-
Looking to upgrade from Sentry SDK 1.x to 2.x? Here's a comprehensive list of what's changed.
3
+
Looking to upgrade from Sentry SDK 1.x to 2.x? Here's a comprehensive list of what's changed. Looking for a more digestable summary? See the [guide in the docs](https://docs.sentry.io/platforms/python/migration/1.x-to-2.x) with the most common migration patterns.
4
4
5
5
## New Features
6
6
7
7
- Additional integrations will now be activated automatically if the SDK detects the respective package is installed: Ariadne, ARQ, asyncpg, Chalice, clickhouse-driver, GQL, Graphene, huey, Loguru, PyMongo, Quart, Starlite, Strawberry.
8
-
-Added new API for custom instrumentation: `new_scope`,`isolation_scope`. See the [Deprecated](#deprecated) section to see how they map to the existing APIs.
8
+
-While refactoring the [inner workings](https://docs.sentry.io/platforms/python/enriching-events/scopes/) of the SDK we added new top-level APIs for custom instrumentation called `new_scope` and`isolation_scope`. See the [Deprecated](#deprecated) section to see how they map to the existing APIs.
9
9
10
10
## Changed
11
11
@@ -118,7 +118,7 @@ Looking to upgrade from Sentry SDK 1.x to 2.x? Here's a comprehensive list of wh
118
118
# do something with the forked scope
119
119
```
120
120
121
-
-`configure_scope`is deprecated. Use the new isolation scope directly via `Scope.get_isolation_scope()` instead.
121
+
-`configure_scope`is deprecated. Modify the current orisolation scope directly instead.
122
122
123
123
Before:
124
124
@@ -132,11 +132,22 @@ Looking to upgrade from Sentry SDK 1.x to 2.x? Here's a comprehensive list of wh
132
132
```python
133
133
from sentry_sdk.scope import Scope
134
134
135
+
scope = Scope.get_current_scope()
136
+
# do something with `scope`
137
+
```
138
+
139
+
Or:
140
+
141
+
```python
142
+
from sentry_sdk.scope import Scope
143
+
135
144
scope = Scope.get_isolation_scope()
136
145
# do something with `scope`
137
146
```
138
147
139
-
-`push_scope`is deprecated. Use the new `new_scope` context manager to fork the necessary scopes.
148
+
When to use `get_current_scope()`and`get_isolation_scope()` depends on how long the change to the scope should be in effect. If you want the changed scope to affect the whole request-response cycle or the whole execution of task, use the isolation scope. If it's more localized, use the current scope.
149
+
150
+
-`push_scope`is deprecated. Fork the current or the isolation scope instead.
140
151
141
152
Before:
142
153
@@ -154,6 +165,17 @@ Looking to upgrade from Sentry SDK 1.x to 2.x? Here's a comprehensive list of wh
154
165
# do something with `scope`
155
166
```
156
167
168
+
Or:
169
+
170
+
```python
171
+
import sentry_sdk
172
+
173
+
with sentry_sdk.isolation_scope() as scope:
174
+
# do something with `scope`
175
+
```
176
+
177
+
`new_scope()` will fork the current scope, while`isolation_scope()` will fork the isolation scope. The lifecycle of a single isolation scope roughly translates to the lifecycle of a transaction in most cases, so if you're looking to create a new separated scope for a whole request-response cycle or task execution, go for `isolation_scope()`. If you want to wrap a smaller unit code, fork the current scope instead with `new_scope()`.
178
+
157
179
- Accessing the client via the hub has been deprecated. Use the top-level `sentry_sdk.get_client()` to get the current client.
158
180
-`profiler_mode`and`profiles_sample_rate` have been deprecated as`_experiments` options. Use them as top level options instead:
0 commit comments