-
Notifications
You must be signed in to change notification settings - Fork 0
Configure Sentry #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Configure Sentry #30
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| from typing import Any | ||
| from urllib.parse import urlparse | ||
|
|
||
| import sentry_sdk | ||
| from asgi_correlation_id import CorrelationIdMiddleware | ||
| from asgi_correlation_id.context import correlation_id | ||
| from celery import Celery | ||
|
|
@@ -28,6 +29,13 @@ | |
| setup_logging(json_logs=settings.LOG_JSON_FORMAT, log_level=settings.LOG_LEVEL) | ||
| access_logger = structlog.stdlib.get_logger("api.access") | ||
|
|
||
| if settings.SENTRY_DSN: | ||
| sentry_sdk.init( | ||
| dsn=settings.SENTRY_DSN, | ||
| environment=settings.RUN_ENV, | ||
| send_default_pii=True, | ||
|
Comment on lines
+34
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some other settings I've seen used in projects are:
For example, the before send settings can help filter out endpoints that we don't need sentry for, like the health endpoint. Could you look into this? 😄 |
||
| ) | ||
|
Comment on lines
31
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would move sentry initialization to the middleware section, to be initialized after the app instance has been created |
||
|
|
||
|
|
||
| # region Instances | ||
| app = FastAPI( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we want sentry when running locally. Can you consult @DanTcheche or @jsarrolt on that?