Skip to content

Commit

Permalink
Sentry support
Browse files Browse the repository at this point in the history
  • Loading branch information
koirikivi committed May 14, 2024
1 parent 989046c commit f2ea1ca
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 1 deletion.
10 changes: 10 additions & 0 deletions bridge_node/bridge/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,21 @@ def index(request):
}


@view_config(route_name="error_trigger", renderer="json")
def error_trigger(request):
1 / 0 # noqa
return {
"error": "grigger",
}


# TODO: do nested config better and separate tapbridge specific views


def includeme(config: Configurator):
config.add_route("error_trigger", "/error-trigger/")
config.add_route("stats", "/stats/")

config.add_route("generate_tap_deposit_address", "/tap/deposit-addresses/")
config.add_route("tap_to_rsk_transfers", "/tap/transfers/")
config.add_route("rsk_to_tap_transfers", "/rsk/transfers/")
Expand Down
5 changes: 5 additions & 0 deletions bridge_node/bridge/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from bridge.decimalcontext import set_decimal_context
from bridge.main_bridge import MainBridge

from .sentry import init_sentry


def main():
logging.basicConfig(
Expand All @@ -25,6 +27,9 @@ def main():
raise RuntimeError("BRIDGE_BTC_NETWORK env variable is not set")
setup_bitcointx_network(btc_network)

sentry_dsn = os.getenv("BRIDGE_SENTRY_DSN")
init_sentry(sentry_dsn)

registries = FactoryRegistrySet()
global_registry = registries.create_registry("global")
transaction_registry = registries.create_registry("transaction")
Expand Down
17 changes: 17 additions & 0 deletions bridge_node/bridge/sentry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import logging
import warnings

import sentry_sdk

logger = logging.getLogger(__name__)


def init_sentry(dsn):
if not dsn:
warnings.warn("Sentry DSN not set, Sentry disabled", stacklevel=2)
return

logger.info("Initializing Sentry")
sentry_sdk.init(
dsn=dsn,
)
52 changes: 51 additions & 1 deletion bridge_node/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 bridge_node/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pyramid = "^2.0.2"
python-dotenv = "^1.0.1"
pyord = "0.3.0"
pyramid-jinja2 = "^2.10.1"
sentry-sdk = "^2.1.1"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.3"
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ services:
- BRIDGE_DISCORD_WEBHOOK_URL=${BRIDGE_DISCORD_WEBHOOK_URL:-}
- BRIDGE_SLACK_WEBHOOK_URL=${BRIDGE_SLACK_WEBHOOK_URL:-}
- BRIDGE_SLACK_WEBHOOK_CHANNEL=${BRIDGE_SLACK_WEBHOOK_CHANNEL:-}
# sentry/etc
- BRIDGE_SENTRY_DSN=${BRIDGE_SENTRY_DSN:-}
# runes rsk
- BRIDGE_RUNES_BTC_RPC_WALLET_URL=${BTC_RPC_RSK_1}
- BRIDGE_SECRET_RUNES_EVM_PRIVATE_KEY=${EVM_PRIVKEY_1}
Expand Down

0 comments on commit f2ea1ca

Please sign in to comment.