diff --git a/poetry.lock b/poetry.lock index 2259cf180..499830a6c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -740,6 +740,34 @@ category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +[[package]] +name = "sentry-sdk" +version = "1.1.0" +description = "Python client for Sentry (https://sentry.io)" +category = "main" +optional = false +python-versions = "*" + +[package.dependencies] +certifi = "*" +urllib3 = ">=1.10.0" + +[package.extras] +aiohttp = ["aiohttp (>=3.5)"] +beam = ["apache-beam (>=2.12)"] +bottle = ["bottle (>=0.12.13)"] +celery = ["celery (>=3)"] +chalice = ["chalice (>=1.16.0)"] +django = ["django (>=1.8)"] +falcon = ["falcon (>=1.4)"] +flask = ["flask (>=0.11)", "blinker (>=1.1)"] +pure_eval = ["pure-eval", "executing", "asttokens"] +pyspark = ["pyspark (>=2.4.4)"] +rq = ["rq (>=0.6)"] +sanic = ["sanic (>=0.8)"] +sqlalchemy = ["sqlalchemy (>=1.2)"] +tornado = ["tornado (>=5)"] + [[package]] name = "six" version = "1.16.0" @@ -829,7 +857,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "39a48a44dc359c18f240d41e353acc698de9eac89b31578f49813f34053b4161" +content-hash = "a361b92403cc710754c02608ff9d7b494409cf67d8c17f2dae5a9251131f56b8" [metadata.files] aiohttp = [ @@ -1409,6 +1437,10 @@ semver = [ {file = "semver-2.13.0-py2.py3-none-any.whl", hash = "sha256:ced8b23dceb22134307c1b8abfa523da14198793d9787ac838e70e29e77458d4"}, {file = "semver-2.13.0.tar.gz", hash = "sha256:fa0fe2722ee1c3f57eac478820c3a5ae2f624af8264cbdf9000c980ff7f75e3f"}, ] +sentry-sdk = [ + {file = "sentry-sdk-1.1.0.tar.gz", hash = "sha256:c1227d38dca315ba35182373f129c3e2722e8ed999e52584e6aca7d287870739"}, + {file = "sentry_sdk-1.1.0-py2.py3-none-any.whl", hash = "sha256:c7d380a21281e15be3d9f67a3c4fbb4f800c481d88ff8d8931f39486dd7b4ada"}, +] six = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, diff --git a/pyproject.toml b/pyproject.toml index 278e913f2..8aaf53c1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ aiosignalrcore = "^0.9.2" fcache = "^0.4.7" click = "^8.0.1" pyee = "^8.1.0" +sentry-sdk = "^1.1.0" [tool.poetry.dev-dependencies] black = "^20.8b1" diff --git a/src/dipdup/cli.py b/src/dipdup/cli.py index a868cae6b..7567ea07f 100644 --- a/src/dipdup/cli.py +++ b/src/dipdup/cli.py @@ -8,7 +8,9 @@ from typing import List, NoReturn import click +import sentry_sdk from fcache.cache import FileCache # type: ignore +from sentry_sdk.integrations.aiohttp import AioHttpIntegration from dipdup import __spec_version__, __version__ from dipdup.config import DipDupConfig, LoggingConfig @@ -80,6 +82,12 @@ async def cli(ctx, config: List[str], logging_config: str): if _config.spec_version != __spec_version__ and ctx.invoked_subcommand != 'migrate': migration_required(_config.spec_version, __spec_version__) + if _config.sentry: + sentry_sdk.init( + dsn=_config.sentry.dsn, + integrations=[AioHttpIntegration()], + ) + ctx.obj = CLIContext( config_paths=config, config=_config, diff --git a/src/dipdup/config.py b/src/dipdup/config.py index 6babb38d8..1ddf421cd 100644 --- a/src/dipdup/config.py +++ b/src/dipdup/config.py @@ -608,6 +608,11 @@ def valid_url(cls, v): return v +@dataclass +class SentryConfig: + dsn: str + + @dataclass class DipDupConfig: """Main dapp config @@ -620,6 +625,7 @@ class DipDupConfig: :param templates: Mapping of template aliases and index templates :param database: Database config :param hasura: Hasura config + :param sentry: Sentry integration config """ spec_version: str @@ -630,6 +636,7 @@ class DipDupConfig: templates: Optional[Dict[str, IndexConfigTemplateT]] = None database: Union[SqliteDatabaseConfig, PostgresDatabaseConfig] = SqliteDatabaseConfig(kind='sqlite') hasura: Optional[HasuraConfig] = None + sentry: Optional[SentryConfig] = None def __post_init_post_parse__(self): self._callback_patterns: Dict[str, List[Sequence[HandlerPatternConfigT]]] = defaultdict(list)