Debugging
This guide covers debugging techniques and tools for TradeX services.
Go Services
Section titled “Go Services”Delve Debugger
Section titled “Delve Debugger”# Install Delvego install github.com/go-delve/delve/cmd/dlv@latest
# Debug servicedlv debug ./cmd/marketdata/main.go
# Attach to running processdlv attach <pid>Logging
Section titled “Logging”logger.Info("Processing order", zap.String("order_id", orderID), zap.String("symbol", symbol), zap.Float64("price", price),)TypeScript Services
Section titled “TypeScript Services”Node.js Debugger
Section titled “Node.js Debugger”# Run with debuggernode --inspect-brk index.ts
# Or with Bunbun --inspect index.tsVS Code Debugging
Section titled “VS Code Debugging”{ "type": "node", "request": "launch", "name": "Debug Service", "runtimeExecutable": "bun", "runtimeArgs": ["run", "dev"], "console": "integratedTerminal"}Python Services
Section titled “Python Services”Python Debugger
Section titled “Python Debugger”# Run with debuggerpython -m pdb -m uvicorn app.main:app
# Or use debugpypython -m debugpy --listen 5678 -m uvicorn app.main:appDistributed Tracing
Section titled “Distributed Tracing”OpenTelemetry
Section titled “OpenTelemetry”View traces in your observability platform:
import { trace } from '@opentelemetry/api';
const tracer = trace.getTracer('my-service');const span = tracer.startSpan('process-order');// ... code ...span.end();Logging
Section titled “Logging”Structured Logging
Section titled “Structured Logging”All services use structured logging:
logger.info('Order processed', { orderId: order.id, symbol: order.symbol, price: order.price});Log Aggregation
Section titled “Log Aggregation”View logs in centralized logging system or:
# View service logsdocker logs tradex-marketdata-service-dev
# Follow logsdocker logs -f tradex-marketdata-service-devCommon Issues
Section titled “Common Issues”Service Not Starting
Section titled “Service Not Starting”- Check port availability
- Verify environment variables
- Check database connectivity
- Review service logs
Performance Issues
Section titled “Performance Issues”- Check metrics (Prometheus)
- Review slow queries
- Check Kafka lag
- Monitor resource usage