MagicTradeBot supports native integration with Sentry — a powerful real-time error tracking and monitoring platform. This allows developers and operators to send structured log and event data from every bot instance to Sentry, enabling fast debugging, centralized alerting, and full visibility into system health.
Whether you're running a single bot instance or hundreds of bots across multiple exchanges, accounts, symbols, or server nodes, Sentry helps you centralize monitoring and trace issues effectively. Manual oversight is not feasible at this scale — Sentry fills this gap with robust automation and insights.
🚀 Overview
With Sentry integration, MagicTradeBot can automatically capture:
- Runtime exceptions and unhandled errors
- Trade execution failures
- Exchange connectivity issues
- Custom logs and diagnostic events
All logs and error events are pushed to Sentry in real-time, allowing you to:
- Trace issues by bot instance, symbol, or exchange
- Analyze stack traces, performance bottlenecks, and error frequency
- Set up email, Slack, or webhook alerts for critical failures
🔧 Key Features
- 📡 Real-time exception and error reporting
- 🧠 Automated stack trace capture with contextual metadata
- 🌍 Multi-instance and distributed environment support
- 🕵️ Issue grouping, severity tagging, and release tracking
- 📊 Centralized dashboard with alert rules and integrations
🛠️ Prerequisites
- A valid Sentry account and DSN (Data Source Name)
- Sentry SDK installed in the MagicTradeBot runtime environment
- Bot configured with unique
instance_id
ortags
for better traceability
⚙️ Configuration Steps
1. Install the Sentry SDK
Install Sentry for your runtime environment (e.g., Python, Go, Node.js):
pip install --upgrade sentry-sdk
2. Initialize Sentry in the Bot Startup Code
Add the following code snippet to initialize Sentry:
import sentry_sdk
sentry_sdk.init(
dsn="YOUR_SENTRY_DSN",
environment="production",
release="magictradebot@2.0.0",
traces_sample_rate=1.0,
send_default_pii=True
)
3. Enable Sentry in Configuration File
In config.yaml
or appsettings.json
, enable Sentry integration:
monitoring:
sentry:
enabled: true
dsn: "YOUR_SENTRY_DSN"
environment: "production"
release: "magictradebot@2.0.0"
tags:
instance_id: "bot-apac-01"
exchange: "binance"
4. Add Custom Log & Error Capture (Optional)
You can manually report critical errors like this:
from sentry_sdk import capture_exception
try:
bot.execute_trade()
except Exception as e:
capture_exception(e)
🧪 Example Sentry Event Payload
{
"level": "error",
"message": "Trade execution failed",
"timestamp": "2025-06-20T11:25:41Z",
"bot_instance": "bot-us-1",
"symbol": "SOL/USDT",
"exchange": "kucoin",
"exception": {
"type": "InsufficientBalanceError",
"value": "Not enough USDT to place order",
"stacktrace": [...]
}
}
✅ Benefits of Sentry Integration
- 📍 Centralized log and error tracking for all bot activity
- ⚠️ Immediate visibility into failures, misconfigurations, or outages
- 📈 Visual dashboards for issue frequency and trends
- 🚨 Alert integrations with Slack, Teams, Email, Webhooks
- 🔍 Faster incident resolution with stack traces and breadcrumbs