Skip to content

Commit

Permalink
Sentry integration (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout authored Jun 28, 2021
1 parent 8bfa178 commit 1e135f6
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
34 changes: 33 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions src/dipdup/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions src/dipdup/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,11 @@ def valid_url(cls, v):
return v


@dataclass
class SentryConfig:
dsn: str


@dataclass
class DipDupConfig:
"""Main dapp config
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 1e135f6

Please sign in to comment.