Skip to content

Commit

Permalink
Add sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
cyc60 committed Dec 26, 2024
1 parent dd4c150 commit e1f09ae
Show file tree
Hide file tree
Showing 6 changed files with 628 additions and 524 deletions.
1,128 changes: 605 additions & 523 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "periodic-tasks"
version = "v0.1.0"
version = "v0.1.1"
description = ""
authors = ["StakeWise Labs <info@stakewise.io>"]
readme = "README.md"
Expand All @@ -12,6 +12,7 @@ gql = {extras = ["requests"], version = "==3.5.0"}
sw-utils = {git = "https://github.com/stakewise/sw-utils.git", rev = "v0.6.25"}
python-decouple = "==3.8"
aiohttp = "==3.10.11"
sentry-sdk = "==2.19.2"

[tool.poetry.group.dev.dependencies]
pylint = "==3.0.1"
Expand Down
15 changes: 15 additions & 0 deletions src/common/sentry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from src.common.settings import NETWORK, SENTRY_DSN


def setup_sentry() -> None:
if not SENTRY_DSN:
return
# pylint: disable-next=import-outside-toplevel
import sentry_sdk

sentry_sdk.init(
SENTRY_DSN,
traces_sample_rate=0.1,
environment=NETWORK.value,
)
sentry_sdk.set_tag('network', NETWORK)
2 changes: 2 additions & 0 deletions src/common/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
EXECUTION_ENDPOINT: str = config('EXECUTION_ENDPOINT', default='')
HOT_WALLET_PRIVATE_KEY: str = config('HOT_WALLET_PRIVATE_KEY')

SENTRY_DSN: str = config('SENTRY_DSN', default='')

NETWORK: Network = config('NETWORK', cast=Network)
network_config = NETWORKS[NETWORK]
2 changes: 2 additions & 0 deletions src/update_ltv.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import logging
import sys

from src.common.sentry import setup_sentry
from src.ltv.tasks import update_vault_max_ltv_user

logger = logging.getLogger(__name__)

try:
setup_sentry()
update_vault_max_ltv_user()
except Exception as e:
logger.error(e)
Expand Down
2 changes: 2 additions & 0 deletions src/update_price.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import logging
import sys

from src.common.sentry import setup_sentry
from src.price.tasks import check_and_sync

logger = logging.getLogger(__name__)


try:
setup_sentry()
check_and_sync()
except Exception as e:
logger.error(e)
Expand Down

0 comments on commit e1f09ae

Please sign in to comment.