Skip to content

Commit f157ae3

Browse files
committed
dev: configure Sentry
1 parent 6e95fc1 commit f157ae3

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

app/config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22

33

44
class Settings(BaseSettings):
5+
# General
6+
ENVIRONMENT: str = "development"
7+
8+
# API keys
59
COINGECKO_API_KEY: str | None = None
610
ALCHEMY_API_KEY: str | None = None
711

12+
# Database config
813
REDIS_HOST: str = "redis-master"
914
REDIS_PORT: int = 6379
1015
REDIS_DB: int = 0
1116
REDIS_PASSWORD: str | None = None
1217

18+
# Monitoring
19+
SENTRY_DSN: str | None = None
1320
PROMETHEUS_PORT: int = 8090
1421

1522
model_config = SettingsConfigDict(env_file=".env")

app/main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import os
12
from contextlib import asynccontextmanager
23

4+
import sentry_sdk
35
from fastapi import FastAPI
46
from prometheus_client import start_http_server
57
from prometheus_fastapi_instrumentator import Instrumentator
@@ -16,6 +18,16 @@
1618
from app.config import settings
1719
from app.core.cache import Cache
1820

21+
version = os.popen("poetry version --short").read().strip()
22+
23+
24+
sentry_sdk.init(
25+
dsn=settings.SENTRY_DSN,
26+
environment=settings.ENVIRONMENT,
27+
release=f"gate3@{version}",
28+
traces_sample_rate=1.0,
29+
)
30+
1931

2032
@asynccontextmanager
2133
async def lifespan_cache(app: FastAPI):

poetry.lock

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "gate3"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
description = "Gate API for web3 applications at Brave"
55
authors = [
66
]
@@ -17,7 +17,8 @@ dependencies = [
1717
"prometheus-fastapi-instrumentator (>=7.1.0,<8.0.0)",
1818
"cachetools (>=6.0.0,<7.0.0)",
1919
"requests (>=2.32.4,<3.0.0)",
20-
"fakeredis[json] (>=2.30.1,<3.0.0)"
20+
"fakeredis[json] (>=2.30.1,<3.0.0)",
21+
"sentry-sdk[fastapi] (>=2.38.0,<3.0.0)"
2122
]
2223

2324

0 commit comments

Comments
 (0)