feat: add sentry sdk

This commit is contained in:
jo 2023-02-26 23:24:29 +01:00 committed by Kyle Robbertze
parent a60d83311b
commit b7214b5d46
14 changed files with 86 additions and 12 deletions

View file

@ -1,3 +1,5 @@
import logging
import os
from pathlib import Path
from typing import Optional
@ -6,10 +8,13 @@ from libretime_shared.cli import cli_config_options, cli_logging_options
from libretime_shared.config import DEFAULT_ENV_PREFIX
from libretime_shared.logging import setup_logger
from . import PACKAGE, VERSION
from .config import Config
from .message_listener import MessageListener
from .status_reporter import StatusReporter
logger = logging.getLogger(__name__)
VERSION = "1.0"
DEFAULT_RETRY_QUEUE_FILEPATH = Path("retry_queue")
@ -36,6 +41,16 @@ def cli(
setup_logger(log_level, log_filepath)
config = Config(config_filepath)
if "SENTRY_DSN" in os.environ:
logger.info("installing sentry")
# pylint: disable=import-outside-toplevel
import sentry_sdk
sentry_sdk.init(
traces_sample_rate=1.0,
release=f"{PACKAGE}@{VERSION}",
)
# Start up the StatusReporter process
StatusReporter.start_thread(retry_queue_filepath)