From fdb9c5cc6029136a997a9003a35b8980ac508cdf Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Sun, 24 Apr 2022 15:03:11 +0300 Subject: [PATCH] Add sentry --- fastapi_file_server/core/app.py | 7 ++++ fastapi_file_server/core/config.py | 2 ++ poetry.lock | 53 +++++++++++++++++++++++++++++- pyproject.toml | 1 + 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/fastapi_file_server/core/app.py b/fastapi_file_server/core/app.py index 98e71b3..96275a8 100644 --- a/fastapi_file_server/core/app.py +++ b/fastapi_file_server/core/app.py @@ -2,12 +2,19 @@ from fastapi import FastAPI from fastapi.responses import ORJSONResponse from prometheus_fastapi_instrumentator import Instrumentator +import sentry_sdk from app.on_start import on_start from app.views import router, healthcheck_router +from core.config import env_config from core.db import database +sentry_sdk.init( + env_config.SENTRY_DSN, +) + + def start_app() -> FastAPI: app = FastAPI(default_response_class=ORJSONResponse) diff --git a/fastapi_file_server/core/config.py b/fastapi_file_server/core/config.py index 7871208..8548c8e 100644 --- a/fastapi_file_server/core/config.py +++ b/fastapi_file_server/core/config.py @@ -28,6 +28,8 @@ class EnvConfig(BaseSettings): TELETHON_APP_CONFIG: Optional[TelethonConfig] TELETHON_SESSIONS: Optional[list[TelethonSessionName]] + SENTRY_DSN: str + class Config: env_file = ".env" env_file_encoding = "utf-8" diff --git a/poetry.lock b/poetry.lock index b3885db..4bcd054 100644 --- a/poetry.lock +++ b/poetry.lock @@ -530,6 +530,36 @@ python-versions = ">=3.6,<4" [package.dependencies] pyasn1 = ">=0.1.3" +[[package]] +name = "sentry-sdk" +version = "1.5.10" +description = "Python client for Sentry (https://sentry.io)" +category = "main" +optional = false +python-versions = "*" + +[package.dependencies] +certifi = "*" +urllib3 = ">=1.10.0" + +[package.extras] +aiohttp = ["aiohttp (>=3.5)"] +beam = ["apache-beam (>=2.12)"] +bottle = ["bottle (>=0.12.13)"] +celery = ["celery (>=3)"] +chalice = ["chalice (>=1.16.0)"] +django = ["django (>=1.8)"] +falcon = ["falcon (>=1.4)"] +flask = ["flask (>=0.11)", "blinker (>=1.1)"] +httpx = ["httpx (>=0.16.0)"] +pure_eval = ["pure-eval", "executing", "asttokens"] +pyspark = ["pyspark (>=2.4.4)"] +quart = ["quart (>=0.16.1)", "blinker (>=1.1)"] +rq = ["rq (>=0.6)"] +sanic = ["sanic (>=0.8)"] +sqlalchemy = ["sqlalchemy (>=1.2)"] +tornado = ["tornado (>=5)"] + [[package]] name = "six" version = "1.16.0" @@ -623,6 +653,19 @@ category = "main" optional = false python-versions = ">=3.6" +[[package]] +name = "urllib3" +version = "1.26.9" +description = "HTTP library with thread-safe connection pooling, file post, and more." +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" + +[package.extras] +brotli = ["brotlicffi (>=0.8.0)", "brotli (>=1.0.9)", "brotlipy (>=0.6.0)"] +secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"] +socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] + [[package]] name = "uvicorn" version = "0.15.0" @@ -663,7 +706,7 @@ python-versions = "*" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "07bd9b0c7bff018be80468a7f665976f2cdb98aabb6dc9071c72bb9914f9c595" +content-hash = "12cb73b598a9196c99c032c1eefaacfcc591468e5d4ae38fb39a3d902ffab5ae" [metadata.files] aiosqlite = [ @@ -1187,6 +1230,10 @@ rsa = [ {file = "rsa-4.8-py3-none-any.whl", hash = "sha256:95c5d300c4e879ee69708c428ba566c59478fd653cc3a22243eeb8ed846950bb"}, {file = "rsa-4.8.tar.gz", hash = "sha256:5c6bd9dc7a543b7fe4304a631f8a8a3b674e2bbfc49c2ae96200cdbe55df6b17"}, ] +sentry-sdk = [ + {file = "sentry-sdk-1.5.10.tar.gz", hash = "sha256:0a9eb20a84f4c17c08c57488d59fdad18669db71ebecb28fb0721423a33535f9"}, + {file = "sentry_sdk-1.5.10-py2.py3-none-any.whl", hash = "sha256:972c8fe9318a415b5cf35f687f568321472ef94b36806407c370ce9c88a67f2e"}, +] six = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, @@ -1243,6 +1290,10 @@ typing-extensions = [ {file = "typing_extensions-4.0.0-py3-none-any.whl", hash = "sha256:829704698b22e13ec9eaf959122315eabb370b0884400e9818334d8b677023d9"}, {file = "typing_extensions-4.0.0.tar.gz", hash = "sha256:2cdf80e4e04866a9b3689a51869016d36db0814d84b8d8a568d22781d45d27ed"}, ] +urllib3 = [ + {file = "urllib3-1.26.9-py2.py3-none-any.whl", hash = "sha256:44ece4d53fb1706f667c9bd1c648f5469a2ec925fcf3a776667042d645472c14"}, + {file = "urllib3-1.26.9.tar.gz", hash = "sha256:aabaf16477806a5e1dd19aa41f8c2b7950dd3c746362d7e3223dbe6de6ac448e"}, +] uvicorn = [ {file = "uvicorn-0.15.0-py3-none-any.whl", hash = "sha256:17f898c64c71a2640514d4089da2689e5db1ce5d4086c2d53699bf99513421c1"}, {file = "uvicorn-0.15.0.tar.gz", hash = "sha256:d9a3c0dd1ca86728d3e235182683b4cf94cd53a867c288eaeca80ee781b2caff"}, diff --git a/pyproject.toml b/pyproject.toml index 172ae07..95ab205 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ psycopg2-binary = "^2.9.3" uvloop = "^0.16.0" gunicorn = "^20.1.0" orjson = "^3.6.7" +sentry-sdk = "^1.5.10" [tool.poetry.dev-dependencies] pytest = "^5.2"