Skip to content

Commit 2d67d71

Browse files
committed
feat(python): Replace experimental logs options with regular ones
1 parent d7fd2a1 commit 2d67d71

File tree

7 files changed

+23
-47
lines changed

7 files changed

+23
-47
lines changed

docs/platforms/python/index.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,15 @@ main()
5454
- `"An exception happened"` will send the current exception from `sys.exc_info()` with the stack trace and everything to the Sentry Python SDK. If there's no exception, the current stack will be attached.
5555
- The debug message `"I am ignored"` will not surface anywhere. To capture it, you need to lower `level` to `DEBUG` (See below).
5656

57-
Log records can additionally also be captured as [Sentry logs](/platforms/python/logs/) as long as the `enable_logs` experimental option is `True`.
57+
Log records can additionally also be captured as [Sentry logs](/platforms/python/logs/) as long as the `enable_logs` option is `True`.
5858

5959
```python
6060
import logging
6161
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")
@@ -102,12 +100,12 @@ You can pass the following keyword arguments to `LoggingIntegration()`:
102100

103101
- `event_level` (default `ERROR`): The Sentry Python SDK will report log records with a level higher than or equal to `event_level` as events as long as the logger itself is set to output records of those log levels (see note below). If a value of `None` occurs, the SDK won't send log records as events.
104102

105-
- `sentry_logs_level` (default `INFO`): The Sentry Python SDK will capture records with a level higher than or equal to `sentry_logs_level` as [Sentry structured logs](/platforms/python/logs/) as long as the `enable_logs` experimental option is `True`.
103+
- `sentry_logs_level` (default `INFO`): The Sentry Python SDK will capture records with a level higher than or equal to `sentry_logs_level` as [Sentry structured logs](/platforms/python/logs/) as long as the `enable_logs` option is `True`.
106104

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: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,15 @@ logger.exception("An exception happened")
6868
- `"An exception happened"` will send the current exception from `sys.exc_info()` with the stack trace to Sentry. If there's no exception, the current stack will be attached.
6969
- The debug message `"I am ignored"` will not be captured by Sentry. To capture it, set `level` to `DEBUG` or lower in `LoguruIntegration`.
7070

71-
Loguru log records can additionally also be captured as [Sentry logs](/platforms/python/logs/) as long as the `enable_logs` experimental option is `True`.
71+
Loguru log records can additionally also be captured as [Sentry logs](/platforms/python/logs/) as long as the `enable_logs` option is `True`.
7272

7373
```python
7474
import sentry_sdk
7575
from loguru import logger
7676

7777
sentry_sdk.init(
7878
# ...
79-
_experiments={
80-
"enable_logs": True,
81-
},
79+
enable_logs=True,
8280
)
8381

8482
logger.info("I will be sent to Sentry logs")
@@ -152,12 +150,12 @@ sentry_sdk.init(
152150

153151
The Sentry Python SDK will capture log records with a level higher than or equal to `sentry_logs_level` as [Sentry structured logs](/platforms/python/logs/). If set to `None`, the SDK won't send records as logs.
154152

155-
To capture Loguru log records as Sentry logs, you must enable the experimental `enable_logs` option when initializing the SDK (regardless of the `sentry_logs_level` setting).
153+
To capture Loguru log records as Sentry logs, you must enable the `enable_logs` option when initializing the SDK (regardless of the `sentry_logs_level` setting).
156154

157155
```python
158156
sentry_sdk.init(
159157
# ...
160-
_experiments={"enable_logs": True},
158+
enable_logs=True,
161159
)
162160
```
163161

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ sentry_sdk.init(
3030
# ___PRODUCT_OPTION_START___ logs
3131

3232
# Enable logs to be sent to Sentry
33-
_experiments={
34-
"enable_logs": True,
35-
},
33+
enable_logs=True,
3634
# ___PRODUCT_OPTION_END___ logs
3735
)
3836
```

platform-includes/logs/integrations/python.mdx

Lines changed: 7 additions & 19 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.
@@ -62,9 +58,7 @@ from sentry_sdk.integrations.logging import LoggingIntegration
6258

6359
sentry_sdk.init(
6460
dsn="___PUBLIC_DSN___",
65-
_experiments={
66-
"enable_logs": True
67-
},
61+
enable_logs=True,
6862
integrations=[
6963
LoggingIntegration(sentry_logs_level=None), # Do not monkeypatch the sentry handler
7064
],
@@ -84,9 +78,7 @@ from loguru import logger
8478

8579
sentry_sdk.init(
8680
dsn="___PUBLIC_DSN___",
87-
_experiments={
88-
"enable_logs": True,
89-
},
81+
enable_logs=True,
9082
)
9183

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

10395
sentry_sdk.init(
10496
dsn="___PUBLIC_DSN___",
105-
_experiments={
106-
"enable_logs": True
107-
},
97+
enable_logs=True,
10898
integrations=[
10999
# Only send WARNING (and higher) logs to Sentry logs
110100
LoguruIntegration(sentry_logs_level=LoggingLevels.WARNING.value),
@@ -125,10 +115,8 @@ from sentry_sdk.integrations.loguru import LoguruIntegration
125115

126116
sentry_sdk.init(
127117
dsn="___PUBLIC_DSN___",
128-
_experiments={
129-
# In general, we want to capture logs as Sentry logs...
130-
"enable_logs": True,
131-
},
118+
# In general, we want to capture logs as Sentry logs...
119+
enable_logs=True,
132120
integrations=[
133121
# ...just not from Loguru
134122
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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
To enable logging, you need to initialize the SDK with the `_experiments["enable_logs"]` option set to `True`.
1+
To enable logging, you need to initialize the SDK with the `enable_logs` option set to `True`.
22

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)