Skip to content

Commit cb8fd54

Browse files
authored
feat(python): Remove experimental logging options (#14678)
documents logging changes made in https://github.com/getsentry/sentry-python/releases/tag/2.35.0, so also bumps the min required sdk version.
1 parent 67e711e commit cb8fd54

File tree

8 files changed

+32
-59
lines changed

8 files changed

+32
-59
lines changed

docs/platforms/python/index.mdx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,19 @@ categories:
1212

1313
## Prerequisites
1414

15-
* You need a Sentry [account](https://sentry.io/signup/) and [project](/product/projects/)
16-
* Read one of our dedicated guides if you use any of the <PlatformLink to="/integrations/#web-frameworks">frameworks</PlatformLink> we support
15+
- You need a Sentry [account](https://sentry.io/signup/) and [project](/product/projects/)
16+
- Read one of our dedicated guides if you use any of the <PlatformLink to="/integrations/#web-frameworks">frameworks</PlatformLink> we support
1717

1818
## Features
1919

20-
<p className="mb-5">Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.</p>
20+
<p className="mb-5">
21+
Select which Sentry features you'd like to install in addition to Error
22+
Monitoring to get the corresponding installation and configuration
23+
instructions below.
24+
</p>
2125

2226
<OnboardingOptionButtons
23-
options={[
24-
'error-monitoring',
25-
'performance',
26-
'profiling',
27-
'logs',
28-
]}
27+
options={["error-monitoring", "performance", "profiling", "logs"]}
2928
/>
3029

3130
## Install
@@ -35,6 +34,7 @@ Install the Sentry SDK using [`pip`](https://pip.pypa.io/en/stable/):
3534
```bash {tabTitle:pip}
3635
pip install "sentry-sdk"
3736
```
37+
3838
```bash {tabTitle:uv}
3939
uv add "sentry-sdk"
4040
```
@@ -43,8 +43,6 @@ uv add "sentry-sdk"
4343

4444
Configuration should happen as **early as possible** in your application's lifecycle.
4545

46-
47-
4846
```python
4947
import sentry_sdk
5048

@@ -69,7 +67,7 @@ sentry_sdk.init(
6967
# ___PRODUCT_OPTION_START___ logs
7068

7169
# Enable logs to be sent to Sentry
72-
_experiments={"enable_logs": True},
70+
enable_logs=True,
7371
# ___PRODUCT_OPTION_END___ logs
7472
)
7573
```

docs/platforms/python/integrations/logging/index.mdx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Install `sentry-sdk` from PyPI:
1212
```bash {tabTitle:pip}
1313
pip install "sentry-sdk"
1414
```
15+
1516
```bash {tabTitle:uv}
1617
uv add "sentry-sdk"
1718
```
@@ -20,7 +21,6 @@ uv add "sentry-sdk"
2021

2122
The logging integrations is a default integration so it will be enabled automatically when you initialize the Sentry SDK.
2223

23-
2424
```python
2525
import sentry_sdk
2626

@@ -62,9 +62,7 @@ import sentry_sdk
6262

6363
sentry_sdk.init(
6464
# ...
65-
_experiments={
66-
"enable_logs": True,
67-
},
65+
enable_logs=True,
6866
)
6967

7068
logging.info("I will be sent to Sentry logs")
@@ -107,7 +105,7 @@ You can pass the following keyword arguments to `LoggingIntegration()`:
107105
```python
108106
sentry_sdk.init(
109107
# ...
110-
_experiments={"enable_logs": True},
108+
enable_logs=True,
111109
)
112110
```
113111

docs/platforms/python/integrations/loguru/index.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Install `sentry-sdk` from PyPI with the `loguru` extra.
1414
```bash {tabTitle:pip}
1515
pip install "sentry-sdk[loguru]"
1616
```
17+
1718
```bash {tabTitle:uv}
1819
uv add "sentry-sdk[loguru]"
1920
```
@@ -22,7 +23,6 @@ uv add "sentry-sdk[loguru]"
2223

2324
If you have the `loguru` package in your dependencies, the Loguru integration will be enabled automatically when you initialize the Sentry SDK.
2425

25-
2626
```python
2727
import sentry_sdk
2828

@@ -157,13 +157,12 @@ sentry_sdk.init(
157157
```python
158158
sentry_sdk.init(
159159
# ...
160-
_experiments={"enable_logs": True},
160+
enable_logs=True,
161161
)
162162
```
163163

164164
Default: `INFO`
165165

166-
167166
## Supported Versions
168167

169168
- Loguru: 0.5+

platform-includes/getting-started-config/python.mdx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
<OnboardingOptionButtons
2-
options={[
3-
'error-monitoring',
4-
'performance',
5-
'profiling',
6-
'logs',
7-
]}
2+
options={["error-monitoring", "performance", "profiling", "logs"]}
83
/>
4+
95
```python
106
import sentry_sdk
117

@@ -30,9 +26,7 @@ sentry_sdk.init(
3026
# ___PRODUCT_OPTION_START___ logs
3127

3228
# Enable logs to be sent to Sentry
33-
_experiments={
34-
"enable_logs": True,
35-
},
29+
enable_logs=True,
3630
# ___PRODUCT_OPTION_END___ logs
3731
)
3832
```

platform-includes/logs/integrations/python.mdx

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import logging
88

99
sentry_sdk.init(
1010
dsn="___PUBLIC_DSN___",
11-
_experiments={
12-
"enable_logs": True,
13-
},
11+
enable_logs=True,
1412
)
1513

1614
# Your existing logging setup
@@ -31,9 +29,7 @@ from sentry_sdk.integrations.logging import LoggingIntegration
3129

3230
sentry_sdk.init(
3331
dsn="___PUBLIC_DSN___",
34-
_experiments={
35-
"enable_logs": True
36-
},
32+
enable_logs=True,
3733
integrations=[
3834
# Only send WARNING (and higher) logs to Sentry logs,
3935
# even if the logger is set to a lower level.
@@ -52,7 +48,6 @@ my_logger.setLevel(logging.ERROR)
5248
my_logger.warning('Now, this log message will not be sent to Sentry logs, since the logger is set to ERROR.')
5349
```
5450

55-
5651
The logging integration automatically monkeypatches a handler into all loggers except for the root logger. If you'd like to manually configure the handler, you can do that like so:
5752

5853
```python
@@ -62,9 +57,7 @@ from sentry_sdk.integrations.logging import LoggingIntegration
6257

6358
sentry_sdk.init(
6459
dsn="___PUBLIC_DSN___",
65-
_experiments={
66-
"enable_logs": True
67-
},
60+
enable_logs=True,
6861
integrations=[
6962
LoggingIntegration(sentry_logs_level=None), # Do not monkeypatch the sentry handler
7063
],
@@ -84,9 +77,7 @@ from loguru import logger
8477

8578
sentry_sdk.init(
8679
dsn="___PUBLIC_DSN___",
87-
_experiments={
88-
"enable_logs": True,
89-
},
80+
enable_logs=True,
9081
)
9182

9283
loguru.debug("In this example, debug events will not be sent to Sentry logs.")
@@ -102,9 +93,7 @@ from sentry_sdk.integrations.loguru import LoggingLevels, LoguruIntegration
10293

10394
sentry_sdk.init(
10495
dsn="___PUBLIC_DSN___",
105-
_experiments={
106-
"enable_logs": True
107-
},
96+
enable_logs=True,
10897
integrations=[
10998
# Only send WARNING (and higher) logs to Sentry logs
11099
LoguruIntegration(sentry_logs_level=LoggingLevels.WARNING.value),
@@ -125,10 +114,8 @@ from sentry_sdk.integrations.loguru import LoguruIntegration
125114

126115
sentry_sdk.init(
127116
dsn="___PUBLIC_DSN___",
128-
_experiments={
129-
# In general, we want to capture logs as Sentry logs...
130-
"enable_logs": True,
131-
},
117+
# In general, we want to capture logs as Sentry logs...
118+
enable_logs=True,
132119
integrations=[
133120
# ...just not from Loguru
134121
LoguruIntegration(sentry_logs_level=None),

platform-includes/logs/options/python.mdx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#### before_send_log
22

3-
To filter logs, or update them before they are sent to Sentry, you can use the `_experiments["before_send_log"]` option.
3+
To filter logs, or update them before they are sent to Sentry, you can use the `before_send_log` option.
44

55
```python
66
import sentry_sdk
@@ -15,10 +15,8 @@ def before_log(log: Log, _hint: Hint) -> Optional[Log]:
1515

1616
sentry_sdk.init(
1717
dsn="___PUBLIC_DSN___",
18-
_experiments={
19-
"enable_logs": True,
20-
"before_send_log": before_log,
21-
},
18+
enable_logs=True,
19+
before_send_log=before_log,
2220
)
2321
```
2422

@@ -31,4 +29,4 @@ The log dict has the following keys:
3129
- `body`: (`str`) The log message.
3230
- `attributes`: (`dict[str, str | bool | float | int]`) Additional attributes to be sent with the log.
3331
- `time_unix_nano`: (`int`) The timestamp of the log in nanoseconds since the Unix epoch.
34-
- `trace_id`: (`Optional[str]`) The trace ID of the trace this log belongs to.
32+
- `trace_id`: (`Optional[str]`) The trace ID of the trace this log belongs to.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
Logs for Python are supported in Sentry Python SDK version `2.28.0` and above.
1+
Logs for Python are supported in Sentry Python SDK version `2.35.0` and above.
22

33
```bash {tabTitle:pip}
44
pip install "sentry-sdk"
55
```
6+
67
```bash {tabTitle:uv}
78
uv add "sentry-sdk"
89
```

platform-includes/logs/setup/python.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ To enable logging, you need to initialize the SDK with the `_experiments["enable
33
```python
44
sentry_sdk.init(
55
dsn="___PUBLIC_DSN___",
6-
_experiments={
7-
"enable_logs": True,
8-
},
6+
enable_logs=True,
97
)
108
```

0 commit comments

Comments
 (0)