aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arthur/__main__.py4
-rw-r--r--arthur/config.py6
-rw-r--r--arthur/log.py21
3 files changed, 30 insertions, 1 deletions
diff --git a/arthur/__main__.py b/arthur/__main__.py
index 6f4a68f..041399b 100644
--- a/arthur/__main__.py
+++ b/arthur/__main__.py
@@ -9,7 +9,7 @@ from discord.ext import commands
import arthur
from arthur.bot import KingArthur
from arthur.config import CONFIG
-from arthur.log import logger
+from arthur.log import logger, setup_sentry
async def main() -> None:
@@ -35,5 +35,7 @@ async def main() -> None:
await bot.start(CONFIG.token.get_secret_value())
+setup_sentry()
+
with logger.catch():
asyncio.run(main())
diff --git a/arthur/config.py b/arthur/config.py
index e9f80d9..c4f7e1a 100644
--- a/arthur/config.py
+++ b/arthur/config.py
@@ -1,5 +1,7 @@
"""Utilities for interacting with the config for King Arthur."""
+from os import environ
+
import pydantic
from pydantic_settings import BaseSettings
@@ -23,6 +25,10 @@ class Config(
devops_role: int = 409416496733880320
guild_id: int = 267624335836053506
+ sentry_dsn: str = ""
+
+
+GIT_SHA = environ.get("GIT_SHA", "development")
CONFIG = Config()
diff --git a/arthur/log.py b/arthur/log.py
index cfc6c62..c382479 100644
--- a/arthur/log.py
+++ b/arthur/log.py
@@ -1,6 +1,27 @@
from functools import partial
import loguru
+import sentry_sdk
+from sentry_sdk.integrations.loguru import LoggingLevels, LoguruIntegration
+
+from arthur.config import CONFIG, GIT_SHA
logger = loguru.logger.opt(colors=True)
logger.opt = partial(logger.opt, colors=True)
+
+
+def setup_sentry() -> None:
+ """Set up the Sentry logging integrations."""
+ loguru_integration = LoguruIntegration(
+ level=LoggingLevels.DEBUG.value, event_level=LoggingLevels.WARNING.value
+ )
+
+ sentry_sdk.init(
+ dsn=CONFIG.sentry_dsn,
+ integrations=[
+ loguru_integration,
+ ],
+ release=f"king-arthur@{GIT_SHA}",
+ traces_sample_rate=0.5,
+ profiles_sample_rate=0.5,
+ )