From b940d599585d7b517a2b28c3062b02dfe3fbe19f Mon Sep 17 00:00:00 2001 From: Zachary Date: Sun, 1 Sep 2024 07:16:12 +0200 Subject: [PATCH] sentry --- app/main.py | 23 ++++++++++++++++++++- poetry.lock | 54 +++++++++++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index e97c9af1b..e40dbb870 100644 --- a/app/main.py +++ b/app/main.py @@ -10,6 +10,20 @@ import numpy as np from app.utils import convert_numpy from app.api import _reformat_context_data +import sentry_sdk + + +sentry_sdk.init( + dsn="https://741dc950f3465d2db0b8f869832dabc0@o4507875835314176.ingest.de.sentry.io/4507875863429200", + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for tracing. + traces_sample_rate=1.0, + # Set profiles_sample_rate to 1.0 to profile 100% + # of sampled transactions. + # We recommend adjusting this value in production. + profiles_sample_rate=1.0, +) + logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) @@ -120,4 +134,11 @@ async def generate_questions(search_query: SearchQuery): async def root(): return {"message": "Welcome to GraphFleet API"} -main = app \ No newline at end of file + +@app.get("/sentry-debug") +async def trigger_error(): + division_by_zero = 1 / 0 + return {"message": "This should never be reached"} + + +main = app diff --git a/poetry.lock b/poetry.lock index 75a1239e9..eb4da25b0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -4671,6 +4671,58 @@ dev = ["flake8", "flit", "mypy", "pandas-stubs", "pre-commit", "pytest", "pytest docs = ["ipykernel", "nbconvert", "numpydoc", "pydata_sphinx_theme (==0.10.0rc2)", "pyyaml", "sphinx (<6.0.0)", "sphinx-copybutton", "sphinx-design", "sphinx-issues"] stats = ["scipy (>=1.7)", "statsmodels (>=0.12)"] +[[package]] +name = "sentry-sdk" +version = "2.13.0" +description = "Python client for Sentry (https://sentry.io)" +optional = false +python-versions = ">=3.6" +files = [ + {file = "sentry_sdk-2.13.0-py2.py3-none-any.whl", hash = "sha256:6beede8fc2ab4043da7f69d95534e320944690680dd9a963178a49de71d726c6"}, + {file = "sentry_sdk-2.13.0.tar.gz", hash = "sha256:8d4a576f7a98eb2fdb40e13106e41f330e5c79d72a68be1316e7852cf4995260"}, +] + +[package.dependencies] +certifi = "*" +fastapi = {version = ">=0.79.0", optional = true, markers = "extra == \"fastapi\""} +urllib3 = ">=1.26.11" + +[package.extras] +aiohttp = ["aiohttp (>=3.5)"] +anthropic = ["anthropic (>=0.16)"] +arq = ["arq (>=0.23)"] +asyncpg = ["asyncpg (>=0.23)"] +beam = ["apache-beam (>=2.12)"] +bottle = ["bottle (>=0.12.13)"] +celery = ["celery (>=3)"] +celery-redbeat = ["celery-redbeat (>=2)"] +chalice = ["chalice (>=1.16.0)"] +clickhouse-driver = ["clickhouse-driver (>=0.2.0)"] +django = ["django (>=1.8)"] +falcon = ["falcon (>=1.4)"] +fastapi = ["fastapi (>=0.79.0)"] +flask = ["blinker (>=1.1)", "flask (>=0.11)", "markupsafe"] +grpcio = ["grpcio (>=1.21.1)", "protobuf (>=3.8.0)"] +httpx = ["httpx (>=0.16.0)"] +huey = ["huey (>=2)"] +huggingface-hub = ["huggingface-hub (>=0.22)"] +langchain = ["langchain (>=0.0.210)"] +litestar = ["litestar (>=2.0.0)"] +loguru = ["loguru (>=0.5)"] +openai = ["openai (>=1.0.0)", "tiktoken (>=0.3.0)"] +opentelemetry = ["opentelemetry-distro (>=0.35b0)"] +opentelemetry-experimental = ["opentelemetry-distro"] +pure-eval = ["asttokens", "executing", "pure-eval"] +pymongo = ["pymongo (>=3.1)"] +pyspark = ["pyspark (>=2.4.4)"] +quart = ["blinker (>=1.1)", "quart (>=0.16.1)"] +rq = ["rq (>=0.6)"] +sanic = ["sanic (>=0.8)"] +sqlalchemy = ["sqlalchemy (>=1.2)"] +starlette = ["starlette (>=0.19.1)"] +starlite = ["starlite (>=1.48)"] +tornado = ["tornado (>=6)"] + [[package]] name = "six" version = "1.16.0" @@ -5854,4 +5906,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = "^3.11.2,<3.13" -content-hash = "5fd30e1d4018eda7aba934c7bdc27836c9c668da96daa9f55774fc6c825d7697" +content-hash = "336ef8b2d5a4da5e88d0b40e98890ef0e40fba4b78d1f65c19784f2374831f93" diff --git a/pyproject.toml b/pyproject.toml index 00e0c9618..08b0e9d39 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ networkx = "^3.0" pydantic-settings = "^2.4.0" streamlit-nightly = "^1.38.1.dev20240828" sseclient-py = "^1.8.0" +sentry-sdk = {extras = ["fastapi"], version = "^2.13.0"}