kocraft-backend/Craft/module/sentry.py

28 lines
736 B
Python
Raw Permalink Normal View History

2024-07-15 08:47:42 +00:00
import os
import sentry_sdk
from dotenv import find_dotenv, load_dotenv
from typing import Union
from sentry_sdk.integrations.fastapi import FastApiIntegration
from sentry_sdk.integrations.loguru import LoguruIntegration
from sentry_sdk.integrations.redis import RedisIntegration
from Craft.enums import LoggingLevel
load_dotenv(find_dotenv())
class Sentry:
def __init__(self):
self.sentry_dsn = os.getenv("SENTRY_DSN")
sentry_sdk.init(
dsn=self.sentry_dsn,
integrations=[
FastApiIntegration(),
LoguruIntegration(),
RedisIntegration(),
],
traces_sample_rate=1.0,
profiles_sample_rate=1.0,
)