Skip to content

Commit

Permalink
only call init on sentry sdk if enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
fullerzz committed Sep 29, 2024
1 parent 513f601 commit 684bf4b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/smolvault/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Settings(BaseSettings):
user_whitelist: str
users_limit: int
daily_upload_limit_bytes: int
sentry_enabled: bool
sentry_dsn: str

model_config = SettingsConfigDict(env_file=".env")
Expand Down
11 changes: 6 additions & 5 deletions src/smolvault/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@
logger = logging.getLogger(__name__)

settings: Settings = get_settings()
sentry_sdk.init(
dsn=settings.sentry_dsn,
traces_sample_rate=1.0, # Set traces_sample_rate to 1.0 to capture 100%
profiles_sample_rate=1.0,
)
if settings.sentry_enabled:
sentry_sdk.init(
dsn=settings.sentry_dsn,
traces_sample_rate=1.0, # Set traces_sample_rate to 1.0 to capture 100%
profiles_sample_rate=1.0,
)

app = FastAPI(title="smolvault", docs_url=None, redoc_url=None)

Expand Down
2 changes: 2 additions & 0 deletions tests/testing.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ SMOLVAULT_CACHE="./uploads/"
USER_WHITELIST="1,2"
USERS_LIMIT="3"
DAILY_UPLOAD_LIMIT_BYTES="50000"
SENTRY_ENABLED="false"
SENTRY_DSN="none"

0 comments on commit 684bf4b

Please sign in to comment.