This commit is contained in:
@@ -79,6 +79,11 @@ class _DatabaseConfig(BaseModel):
|
||||
return cast(str, self.uri_plain)
|
||||
|
||||
|
||||
class _SentryConfig(BaseModel):
|
||||
# The Sentry DSN.
|
||||
dsn: str
|
||||
|
||||
|
||||
class _Config(BaseModel):
|
||||
# Database config
|
||||
database: _DatabaseConfig
|
||||
@@ -86,6 +91,9 @@ class _Config(BaseModel):
|
||||
# Component configuration
|
||||
component: _ComponentConfig
|
||||
|
||||
# Optional Sentry config
|
||||
sentry: _SentryConfig | None
|
||||
|
||||
|
||||
@cache
|
||||
def load_config() -> _Config:
|
||||
|
||||
@@ -30,6 +30,16 @@ def startup():
|
||||
engine = app.dependency_overrides.get(get_engine, get_engine)(config)
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
if config.sentry is not None:
|
||||
logging.getLogger("root").info("Setting up Sentry")
|
||||
import sentry_sdk
|
||||
sentry_sdk.init(
|
||||
config.sentry.dsn,
|
||||
send_default_pii=True,
|
||||
max_request_body_size="always",
|
||||
traces_sample_rate=0,
|
||||
)
|
||||
|
||||
# App startup is done. Connect to the XMPP server
|
||||
instance = XmppApiComponent.of(config)
|
||||
instance.run()
|
||||
|
||||
Reference in New Issue
Block a user