Skip to content

Conversation

@liuhetian
Copy link

follow sentry's suggestion and example,
put init before app has been initialized

If you have the fastapi package in your dependencies, the FastAPI integration will be enabled automatically when you initialize the Sentry SDK. Initialize the Sentry SDK before your app has been initialized:

from fastapi import FastAPI
import sentry_sdk

sentry_sdk.init(
    dsn="https://foo.ingest.us.sentry.io/bar",
    # Add data like request headers and IP for users,
    # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
    send_default_pii=True,
)

app = FastAPI()

follow sentry's suggestion and example,
put init before app has been initialized

> If you have the fastapi package in your dependencies, the FastAPI integration will be enabled automatically when you initialize the Sentry SDK. Initialize the Sentry SDK before your app has been initialized:

```
from fastapi import FastAPI
import sentry_sdk

sentry_sdk.init(
    dsn="https://foo.ingest.us.sentry.io/bar",
    # Add data like request headers and IP for users,
    # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
    send_default_pii=True,
)

app = FastAPI()
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant