(summary) enable sentry monitoring

Necessary to monitor how the micro service acts.
Will tweak sentry configurations later on.
This commit is contained in:
lebaudantoine
2024-12-01 22:01:53 +01:00
committed by aleb_the_flash
parent a6b6cb7787
commit e6377ce182
5 changed files with 21 additions and 2 deletions

View File

@@ -271,6 +271,8 @@ celery:
secretKeyRef: secretKeyRef:
name: redis-summary.redis.libre.sh name: redis-summary.redis.libre.sh
key: url key: url
SENTRY_IS_ENABLED: True
SENTRY_DSN: https://5aead03f03505da5130af6d642c42faf@sentry.incubateur.net/202
image: image:
repository: lasuite/meet-summary repository: lasuite/meet-summary

View File

@@ -12,6 +12,7 @@ dependencies = [
"minio==7.2.9", "minio==7.2.9",
"openai==1.51.2", "openai==1.51.2",
"requests==2.32.3", "requests==2.32.3",
"sentry-sdk[fastapi, celery]==2.19.0",
] ]
[project.optional-dependencies] [project.optional-dependencies]

View File

@@ -5,7 +5,8 @@ import tempfile
from pathlib import Path from pathlib import Path
import openai import openai
from celery import Celery import sentry_sdk
from celery import Celery, signals
from celery.utils.log import get_task_logger from celery.utils.log import get_task_logger
from minio import Minio from minio import Minio
from requests import Session from requests import Session
@@ -26,6 +27,12 @@ celery = Celery(
broker_connection_retry_on_startup=True, broker_connection_retry_on_startup=True,
) )
if settings.sentry_dsn and settings.sentry_is_enabled:
@signals.celeryd_init.connect
def init_sentry(**_kwargs):
"""Initialize sentry."""
sentry_sdk.init(dsn=settings.sentry_dsn, enable_tracing=True)
def save_audio_stream(audio_stream, chunk_size=32 * 1024): def save_audio_stream(audio_stream, chunk_size=32 * 1024):
"""Save an audio stream to a temporary OGG file.""" """Save an audio stream to a temporary OGG file."""

View File

@@ -1,7 +1,7 @@
"""Application configuration and settings.""" """Application configuration and settings."""
from functools import lru_cache from functools import lru_cache
from typing import Annotated from typing import Annotated, Optional
from fastapi import Depends from fastapi import Depends
from pydantic_settings import BaseSettings, SettingsConfigDict from pydantic_settings import BaseSettings, SettingsConfigDict
@@ -41,6 +41,10 @@ class Settings(BaseSettings):
webhook_api_token: str webhook_api_token: str
webhook_url: str webhook_url: str
# Sentry
sentry_is_enabled: bool = False
sentry_dsn: Optional[str] = None
@lru_cache @lru_cache
def get_settings(): def get_settings():

View File

@@ -1,5 +1,6 @@
"""Application.""" """Application."""
import sentry_sdk
from fastapi import FastAPI from fastapi import FastAPI
from summary.api import health from summary.api import health
@@ -8,6 +9,10 @@ from summary.core.config import get_settings
settings = get_settings() settings = get_settings()
if settings.sentry_dsn and settings.sentry_is_enabled:
sentry_sdk.init(dsn=settings.sentry_dsn, enable_tracing=True)
app = FastAPI( app = FastAPI(
title=settings.app_name, title=settings.app_name,
) )