Skip to content

Commit 7659554

Browse files
authored
ref(docs): Deprecate old hub API in migration guide (#2868)
1 parent 37adf4a commit 7659554

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

MIGRATION_GUIDE.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Looking to upgrade from Sentry SDK 1.x to 2.x? Here's a comprehensive list of wh
55
## New Features
66

77
- 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.
89

910
## Changed
1011

@@ -76,6 +77,79 @@ Looking to upgrade from Sentry SDK 1.x to 2.x? Here's a comprehensive list of wh
7677

7778
## Deprecated
7879

80+
- Using the `Hub` directly as well as using hub-based APIs has been deprecated. Where available, use [the top-level API instead](sentry_sdk/api.py); otherwise use the [scope API](sentry_sdk/scope.py) or the [client API](sentry_sdk/client.py).
81+
82+
Before:
83+
84+
```python
85+
with hub.start_span(...):
86+
# do something
87+
```
88+
89+
After:
90+
91+
```python
92+
import sentry_sdk
93+
94+
with sentry_sdk.start_span(...):
95+
# do something
96+
```
97+
98+
- Hub cloning is deprecated.
99+
100+
Before:
101+
102+
```python
103+
with Hub(Hub.current) as hub:
104+
# do something with the cloned hub
105+
```
106+
107+
After:
108+
109+
```python
110+
import sentry_sdk
111+
112+
with sentry_sdk.isolation_scope() as scope:
113+
# do something with the forked scope
114+
```
115+
116+
- `configure_scope` is deprecated. Use the new isolation scope directly via `Scope.get_isolation_scope()` instead.
117+
118+
Before:
119+
120+
```python
121+
with configure_scope() as scope:
122+
# do something with `scope`
123+
```
124+
125+
After:
126+
127+
```python
128+
from sentry_sdk.scope import Scope
129+
130+
scope = Scope.get_isolation_scope()
131+
# do something with `scope`
132+
```
133+
134+
- `push_scope` is deprecated. Use the new `new_scope` context manager to fork the necessary scopes.
135+
136+
Before:
137+
138+
```python
139+
with push_scope() as scope:
140+
# do something with `scope`
141+
```
142+
143+
After:
144+
145+
```python
146+
import sentry_sdk
147+
148+
with sentry_sdk.new_scope() as scope:
149+
# do something with `scope`
150+
```
151+
152+
- Accessing the client via the hub has been deprecated. Use the top-level `sentry_sdk.get_client()` to get the current client.
79153
- `profiler_mode` and `profiles_sample_rate` have been deprecated as `_experiments` options. Use them as top level options instead:
80154
```python
81155
sentry_sdk.init(

0 commit comments

Comments
 (0)