From 1c9bf86395b23fad17b4180c46f30fabb533c562 Mon Sep 17 00:00:00 2001 From: Olivier Giorgis <ogiorgis@logilab.fr> Date: Fri, 30 Aug 2024 11:21:09 +0200 Subject: [PATCH] feat: add sentry to project --- config.toml.example | 3 +++ git_hg_sync/__main__.py | 5 +++++ git_hg_sync/config.py | 5 +++++ pyproject.toml | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/config.toml.example b/config.toml.example index 3c9894b..4319882 100644 --- a/config.toml.example +++ b/config.toml.example @@ -8,6 +8,9 @@ queue = "queue/<username>/test" password = "<pulse-password>" ssl = true +[sentry] +sentry_url = "" + [clones] directory = "../git_hg_sync_repos/" diff --git a/git_hg_sync/__main__.py b/git_hg_sync/__main__.py index 7cf9109..5b773ae 100644 --- a/git_hg_sync/__main__.py +++ b/git_hg_sync/__main__.py @@ -2,6 +2,7 @@ import sys from pathlib import Path +import sentry_sdk from kombu import Connection, Exchange, Queue from mozlog import commandline @@ -69,6 +70,10 @@ def main() -> None: args = parser.parse_args() logger = commandline.setup_logging("service", args, {"raw": sys.stdout}) config = Config.from_file(args.config) + sentry_config = config.sentry + if sentry_config and sentry_config.sentry_url: + logger.info(f"sentry url: {sentry_config.sentry_url}") + sentry_sdk.init(sentry_config.sentry_url) start_app(config, logger) diff --git a/git_hg_sync/config.py b/git_hg_sync/config.py index 274ba8b..9fc140e 100644 --- a/git_hg_sync/config.py +++ b/git_hg_sync/config.py @@ -27,8 +27,13 @@ class ClonesConfig(pydantic.BaseModel): directory: pathlib.Path +class SentryConfig(pydantic.BaseModel): + sentry_url: str | None = None + + class Config(pydantic.BaseModel): pulse: PulseConfig + sentry: SentryConfig | None = None clones: ClonesConfig tracked_repositories: list[TrackedRepository] mappings: list[Mapping] diff --git a/pyproject.toml b/pyproject.toml index aa215b1..90b60c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "git-hg-sync" readme = "README.md" requires-python = ">=3.10" version = "0.1" -dependencies = ['kombu', 'mozillapulse', 'GitPython', 'mozlog', "pydantic"] +dependencies = ['kombu', 'mozillapulse', 'GitPython', 'mozlog', "pydantic", "sentry_sdk"] [tool.ruff] line-length = 100