Skip to content
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

chore: Make Sentry config optional #1066

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ GOOGLE_IOS_CLIENT_ID=google-mobile-client-id
MAPBOX_USERNAME=mapbox-username
MAPBOX_ACCESS_TOKEN=your-mapbox-token

SENTRY_DSN=https://xyz.ingest.sentry.io/abcd
# Uncomment and populate with a DSN to enable sentry.
paulschreiber marked this conversation as resolved.
Show resolved Hide resolved
# SENTRY_DSN=https://xyz.ingest.sentry.io/abcd
26 changes: 15 additions & 11 deletions terraso_backend/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,18 @@ class JWTProvider(TypedDict):
MAPBOX_USERNAME = config("MAPBOX_USERNAME", default="")
MAPBOX_ACCESS_TOKEN = config("MAPBOX_ACCESS_TOKEN", default="")

sentry_sdk.init(
dsn=config("SENTRY_DSN", default=""),
environment=config("ENV", default="development"),
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
traces_sample_rate=1.0,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
)
if config("SENTRY_DSN", default=""):
sentry_sdk.init(
dsn=config("SENTRY_DSN", default=""),
environment=config("ENV", default="development"),
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
traces_sample_rate=1.0,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
)
else:
# structlog is already set up at this point, so we can log nicely.
structlog.get_logger().warning("SENTRY_DSN is not defined, continuing without Sentry.")