(feat) добавлена интеграция с sentry
This commit is contained in:
@@ -5,7 +5,10 @@ from fastapi.middleware.cors import CORSMiddleware
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
import logging
|
||||
|
||||
from apiApp.config import APP_TITLE, APP_VERSION, API_V1_PREFIX, UPLOAD_FOLDER, DATABASE_URL, PORT, HOST
|
||||
from apiApp.config import (
|
||||
APP_TITLE, APP_VERSION, API_V1_PREFIX, UPLOAD_FOLDER, DATABASE_URL, PORT, HOST,
|
||||
SENTRY_DSN, SENTRY_ENVIRONMENT, SENTRY_TRACES_SAMPLE_RATE, SENTRY_PROFILES_SAMPLE_RATE, SENTRY_SEND_DEFAULT_PII
|
||||
)
|
||||
from apiApp.database import engine, Base
|
||||
from apiApp.routers import audio_router, recognition_router
|
||||
from apiApp.routers.ai_conclusion_router import ai_conclusion_router
|
||||
@@ -19,6 +22,20 @@ print("✅ audio_management_router imported successfully")
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Инициализация Sentry SDK до создания FastAPI приложения
|
||||
if SENTRY_DSN:
|
||||
import sentry_sdk
|
||||
|
||||
sentry_sdk.init(
|
||||
dsn=SENTRY_DSN,
|
||||
traces_sample_rate=SENTRY_TRACES_SAMPLE_RATE,
|
||||
profiles_sample_rate=SENTRY_PROFILES_SAMPLE_RATE,
|
||||
send_default_pii=SENTRY_SEND_DEFAULT_PII,
|
||||
environment=SENTRY_ENVIRONMENT,
|
||||
release=f"speech-fileaudio-api@{APP_VERSION}",
|
||||
)
|
||||
logger.info("✅ Sentry initialized for speech-fileaudio-api")
|
||||
|
||||
# Создание FastAPI приложения
|
||||
app = FastAPI(
|
||||
title=APP_TITLE,
|
||||
@@ -28,6 +45,13 @@ app = FastAPI(
|
||||
openapi_url=f"{API_V1_PREFIX}/openapi.json"
|
||||
)
|
||||
|
||||
@app.get("/sentry-debug")
|
||||
async def trigger_sentry_debug():
|
||||
"""Эндпоинт для проверки интеграции Sentry"""
|
||||
division_by_zero = 1 / 0
|
||||
return {"status": "ok"}
|
||||
|
||||
|
||||
# CORS middleware
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
|
||||
Reference in New Issue
Block a user