(feat) добавлена интеграция с sentry
This commit is contained in:
@@ -15,3 +15,11 @@
|
|||||||
# HOST=0.0.0.0
|
# HOST=0.0.0.0
|
||||||
# PORT=8000
|
# PORT=8000
|
||||||
# RELOAD=True
|
# RELOAD=True
|
||||||
|
|
||||||
|
# Sentry Configuration
|
||||||
|
# SENTRY_DSN=https://a5da7e2cd15fd85150e012a6d62fc13c@sentry.pirogov.ai/26
|
||||||
|
# SENTRY_ENVIRONMENT=production
|
||||||
|
# SENTRY_TRACES_SAMPLE_RATE=0.2
|
||||||
|
# SENTRY_PROFILES_SAMPLE_RATE=0.1
|
||||||
|
# SENTRY_SEND_DEFAULT_PII=true
|
||||||
|
|
||||||
|
|||||||
@@ -26,3 +26,11 @@ FILESAPTH = audiofiles
|
|||||||
GIGAAM_API_URL = http://host.docker.internal:5002
|
GIGAAM_API_URL = http://host.docker.internal:5002
|
||||||
CALLS_WEB_CLIENT_URL=http://web_client_test:8642
|
CALLS_WEB_CLIENT_URL=http://web_client_test:8642
|
||||||
AUDIO_FILES_PATH_TEST=D:\SpeechAnalitics\audiofiles
|
AUDIO_FILES_PATH_TEST=D:\SpeechAnalitics\audiofiles
|
||||||
|
|
||||||
|
# Sentry Configuration
|
||||||
|
SENTRY_DSN=https://a5da7e2cd15fd85150e012a6d62fc13c@sentry.pirogov.ai/26
|
||||||
|
SENTRY_ENVIRONMENT=test
|
||||||
|
SENTRY_TRACES_SAMPLE_RATE=0.2
|
||||||
|
SENTRY_PROFILES_SAMPLE_RATE=0.1
|
||||||
|
SENTRY_SEND_DEFAULT_PII=true
|
||||||
|
|
||||||
|
|||||||
@@ -44,3 +44,10 @@ AUTO_RESTORE_DELAY = int(os.getenv("AUTO_RESTORE_DELAY", "5")) # Задержк
|
|||||||
|
|
||||||
# Recognition retry policy (FileAudioAPI side)
|
# Recognition retry policy (FileAudioAPI side)
|
||||||
MAX_RECOGNITION_ATTEMPTS = int(os.getenv("MAX_RECOGNITION_ATTEMPTS", "3"))
|
MAX_RECOGNITION_ATTEMPTS = int(os.getenv("MAX_RECOGNITION_ATTEMPTS", "3"))
|
||||||
|
|
||||||
|
# Sentry Configuration
|
||||||
|
SENTRY_DSN = os.getenv("SENTRY_DSN", "")
|
||||||
|
SENTRY_ENVIRONMENT = os.getenv("SENTRY_ENVIRONMENT", "production")
|
||||||
|
SENTRY_TRACES_SAMPLE_RATE = float(os.getenv("SENTRY_TRACES_SAMPLE_RATE", "0.2"))
|
||||||
|
SENTRY_PROFILES_SAMPLE_RATE = float(os.getenv("SENTRY_PROFILES_SAMPLE_RATE", "0.1"))
|
||||||
|
SENTRY_SEND_DEFAULT_PII = os.getenv("SENTRY_SEND_DEFAULT_PII", "true").lower() == "true"
|
||||||
@@ -5,7 +5,10 @@ from fastapi.middleware.cors import CORSMiddleware
|
|||||||
from sqlalchemy.exc import SQLAlchemyError
|
from sqlalchemy.exc import SQLAlchemyError
|
||||||
import logging
|
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.database import engine, Base
|
||||||
from apiApp.routers import audio_router, recognition_router
|
from apiApp.routers import audio_router, recognition_router
|
||||||
from apiApp.routers.ai_conclusion_router import ai_conclusion_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)
|
logging.basicConfig(level=logging.INFO)
|
||||||
logger = logging.getLogger(__name__)
|
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 приложения
|
# Создание FastAPI приложения
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title=APP_TITLE,
|
title=APP_TITLE,
|
||||||
@@ -28,6 +45,13 @@ app = FastAPI(
|
|||||||
openapi_url=f"{API_V1_PREFIX}/openapi.json"
|
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
|
# CORS middleware
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
|
|||||||
@@ -7,3 +7,4 @@ aiofiles==24.1.0
|
|||||||
psycopg2-binary
|
psycopg2-binary
|
||||||
paramiko
|
paramiko
|
||||||
requests
|
requests
|
||||||
|
sentry-sdk[fastapi]>=2.0.0
|
||||||
Reference in New Issue
Block a user