Skip to content

Commit 1de623e

Browse files
Updated Starlette/FastAPI setup documentation (#5472)
The integrations for Python Starlette and FastAPI are now auto enabled. Changed the documentation to reflect that. Co-authored-by: Isabel <[email protected]>
1 parent e7ea659 commit 1de623e

File tree

4 files changed

+12
-40
lines changed

4 files changed

+12
-40
lines changed

src/platforms/python/guides/fastapi/index.mdx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ description: "Learn about using Sentry with FastAPI."
88

99
The FastAPI integration adds support for the [FastAPI Framework](https://fastapi.tiangolo.com/).
1010

11+
The Sentry SDK automatically enables support for FastAPI if you have the `fastapi` Python package installed in your project. There are no configuration options you need to add when initializing the Sentry SDK as everything works out of the box.
12+
1113
## Install
1214

1315
Install `sentry-sdk` from PyPI with the `fastapi` extra:
@@ -24,16 +26,10 @@ To configure the SDK, initialize it with the integration before your app has bee
2426
from fastapi import FastAPI
2527

2628
import sentry_sdk
27-
from sentry_sdk.integrations.starlette import StarletteIntegration
28-
from sentry_sdk.integrations.fastapi import FastApiIntegration
2929

3030

3131
sentry_sdk.init(
3232
dsn="___PUBLIC_DSN___",
33-
integrations=[
34-
StarletteIntegration(),
35-
FastApiIntegration(),
36-
],
3733

3834
# Set traces_sample_rate to 1.0 to capture 100%
3935
# of transactions for performance monitoring.
@@ -44,14 +40,6 @@ sentry_sdk.init(
4440
app = FastAPI()
4541
```
4642

47-
Because FastAPI is based on the Starlette framework, you need to enable both `StarletteIntegration` and `FastApiIntegration`.
48-
49-
<Note>
50-
51-
In the future, we will make this auto-enabling, so you won't need to add the `StarletteIntegration` to your `sentry_sdk.init()` call. Instead, the Sentry SDK will detect the presence of Starlette and will set up the integration automatically.
52-
53-
</Note>
54-
5543
## Verify
5644

5745
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up:
@@ -80,9 +68,11 @@ Visiting `"/sentry-debug"` will trigger an error that will be captured by Sentry
8068

8169
## Options
8270

83-
You can pass the following keyword arguments to `FastApiIntegration()`:
71+
If you want to change the default behavior of the FastAPI integration, you need to instantiate the integration by hand and pass it to Sentry's `init` function.
72+
73+
Because FastAPI is based on the Starlette framework, both integrations `StarletteIntegration` and `FastApiIntegration`, must be instantiated.
8474

85-
- `transaction_style`:
75+
You can pass the keyword argument `transaction_style` to `StarletteIntegration()` and `FastApiIntegration()`.
8676

8777
With this option, you can influence how the transactions are named in Sentry. For example:
8878

src/platforms/python/guides/starlette/index.mdx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ description: "Learn about using Sentry with Starlette."
88

99
The Starlette integration adds support for the [Starlette Framework](https://www.starlette.io/).
1010

11+
The Sentry SDK automatically enables support for Starlette if you have the `starlette` Python package installed in your project. There are no configuration options you need to add when initializing the Sentry SDK, as everything works out of the box.
12+
1113
## Install
1214

1315
Install `sentry-sdk` from PyPI with the `starlette` extra:
@@ -24,14 +26,10 @@ To configure the SDK, initialize it with the integration before your app has bee
2426
from starlette.applications import Starlette
2527

2628
import sentry_sdk
27-
from sentry_sdk.integrations.starlette import StarletteIntegration
2829

2930

3031
sentry_sdk.init(
3132
dsn="___PUBLIC_DSN___",
32-
integrations=[
33-
StarletteIntegration(),
34-
],
3533

3634
# Set traces_sample_rate to 1.0 to capture 100%
3735
# of transactions for performance monitoring.
@@ -42,12 +40,6 @@ sentry_sdk.init(
4240
app = Starlette(routes=[...])
4341
```
4442

45-
<Note>
46-
47-
In the future, we will make this auto-enabling, so you won't need to add the `StarletteIntegration` to your `sentry_sdk.init()` call. Instead, the Sentry SDK will detect the presence of Starlette and will set up the integration automatically.
48-
49-
</Note>
50-
5143
## Verify
5244

5345
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up:
@@ -77,9 +69,9 @@ Visiting `"/sentry-debug"` will trigger an error that will be captured by Sentry
7769

7870
## Options
7971

80-
You can pass the following keyword arguments to `StarletteIntegration()`:
72+
If you want to change the default behavior of the Starlette integration, you need to instantiate the integration by hand and pass it to Sentry's `init` function.
8173

82-
- `transaction_style`:
74+
You can pass the keyword argument `transaction_style` to `StarletteIntegration()`.
8375

8476
With this option, you can influence how the transactions are named in Sentry. For example:
8577

src/wizard/python/fastapi.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,16 @@ The FastAPI integration adds support for the [FastAPI Framework](https://fastapi
1313
pip install --upgrade 'sentry-sdk[fastapi]'
1414
```
1515

16-
2. To configure the SDK, initialize it with the integration before your app has been initialized:
16+
2. To configure the SDK, initialize it before your app has been initialized. The Sentry SDK automatically enables support for FastAPI if you have the `fastapi` Python package installed in your project. There are no configuration options you need to add when initializing the Sentry SDK as everything works out of the box:
1717

1818
```python
1919
from fastapi import FastAPI
2020

2121
import sentry_sdk
22-
from sentry_sdk.integrations.starlette import StarletteIntegration
23-
from sentry_sdk.integrations.fastapi import FastApiIntegration
2422

2523

2624
sentry_sdk.init(
2725
dsn="___PUBLIC_DSN___",
28-
integrations=[
29-
StarletteIntegration(),
30-
FastApiIntegration(),
31-
],
3226

3327
# Set traces_sample_rate to 1.0 to capture 100%
3428
# of transactions for performance monitoring.

src/wizard/python/starlette.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,16 @@ The Starlette integration adds support for the [Starlette Framework](https://www
1313
pip install --upgrade 'sentry-sdk[starlette]'
1414
```
1515

16-
2. To configure the SDK, initialize it with the integration before your app has been initialized:
16+
2. To configure the SDK, initialize it before your app has been initialized. The Sentry SDK automatically enables support for Starlette if you have the `starlette` Python package installed in your project. There are no configuration options you need to add when initializing the Sentry SDK as everything works out of the box:
1717

1818
```python
1919
from starlette.applications import Starlette
2020

2121
import sentry_sdk
22-
from sentry_sdk.integrations.starlette import StarletteIntegration
2322

2423

2524
sentry_sdk.init(
2625
dsn="___PUBLIC_DSN___",
27-
integrations=[
28-
StarletteIntegration(),
29-
],
3026

3127
# Set traces_sample_rate to 1.0 to capture 100%
3228
# of transactions for performance monitoring.

0 commit comments

Comments
 (0)