Skip to content

Commit

Permalink
Configure sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
ipdae committed Nov 2, 2023
1 parent 8e0ad33 commit 6825f2a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ celery-types = "^0.14.0"
pydantic = {extras = ["dotenv"], version = "^1.10.2"}
bencodex = "^1.0.1"
gql = {version = "^3.5.0b0", allow-prereleases = true}
sentry-sdk = {extras = ["flask"], version = "^1.33.1"}


[tool.poetry.group.dev.dependencies]
Expand Down
6 changes: 6 additions & 0 deletions world_boss/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class Settings(BaseSettings):
celery_broker_url: str = f"{default_redis_url}/0"
celery_result_backend: str = f"{default_redis_url}/1"
slack_signing_secret: str
sentry_dsn: str = ""
sentry_sample_rate: float = 0.1

class Config:
env_file = ".env"
Expand All @@ -48,6 +50,10 @@ class Config:
"env": "CELERY_RESULT_BACKEND",
},
"slack_signing_secret": {"env": "SLACK_SIGNING_SECRET"},
"sentry_dsn": {
"env": "SENTRY_DSN",
},
"sentry_sample_rate": {"env": "SENTRY_SAMPLE_RATE"},
}


Expand Down
6 changes: 6 additions & 0 deletions world_boss/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sentry_sdk
from flask import Flask
from sqlalchemy.exc import OperationalError

Expand All @@ -8,6 +9,11 @@


def create_app() -> Flask:
sentry_sdk.init(
dsn=config.sentry_dsn,
enable_tracing=True,
traces_sample_rate=config.sentry_sample_rate,
)
flask_app = Flask(__name__)
flask_app.config["SQLALCHEMY_DATABASE_URI"] = config.database_url
flask_app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
Expand Down

0 comments on commit 6825f2a

Please sign in to comment.