Enhance OKXCollector with improved heartbeat and logging functionality
- Added logger parameter to the OKXCollector to enable detailed ping/pong logging. - Updated message processing methods to maintain heartbeat and track data reception timestamps. - Adjusted ProductionManager to disable auto-restart and enable full logging for debugging WebSocket issues. - Enhanced overall logging capabilities to facilitate better monitoring and troubleshooting of data collection processes.
This commit is contained in:
parent
bc13cfcbe0
commit
cecb5fd411
@ -145,7 +145,8 @@ class OKXCollector(BaseDataCollector):
|
||||
ping_interval=25.0,
|
||||
pong_timeout=10.0,
|
||||
max_reconnect_attempts=5,
|
||||
reconnect_delay=5.0
|
||||
reconnect_delay=5.0,
|
||||
logger=self.logger # Pass the logger to enable ping/pong logging
|
||||
)
|
||||
|
||||
# Add message callback
|
||||
@ -346,6 +347,16 @@ class OKXCollector(BaseDataCollector):
|
||||
"""Handle message processing in the background."""
|
||||
# The new data processor handles messages through callbacks
|
||||
# This method exists for compatibility with BaseDataCollector
|
||||
|
||||
# Update heartbeat to indicate the message loop is active
|
||||
self._last_heartbeat = datetime.now(timezone.utc)
|
||||
|
||||
# Check if we're receiving WebSocket messages
|
||||
if self._ws_client and self._ws_client.is_connected:
|
||||
# Update last data received timestamp if WebSocket is connected and active
|
||||
self._last_data_received = datetime.now(timezone.utc)
|
||||
|
||||
# Short sleep to prevent busy loop while maintaining heartbeat
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
async def _store_processed_data(self, data_point: MarketDataPoint) -> None:
|
||||
@ -443,6 +454,12 @@ class OKXCollector(BaseDataCollector):
|
||||
message: WebSocket message from OKX
|
||||
"""
|
||||
try:
|
||||
# Update heartbeat and data received timestamps
|
||||
current_time = datetime.now(timezone.utc)
|
||||
self._last_heartbeat = current_time
|
||||
self._last_data_received = current_time
|
||||
self._message_count += 1
|
||||
|
||||
# Process message asynchronously
|
||||
asyncio.create_task(self._process_message(message))
|
||||
except Exception as e:
|
||||
|
||||
@ -123,11 +123,11 @@ class ProductionManager:
|
||||
symbol=symbol,
|
||||
data_types=data_types,
|
||||
component_name=f"okx_collector_{symbol.replace('-', '_').lower()}",
|
||||
auto_restart=self.config.get('data_collection', {}).get('auto_restart', True),
|
||||
health_check_interval=self.config.get('data_collection', {}).get('health_check_interval', 30.0),
|
||||
auto_restart=False, # Disable auto-restart to prevent health check interference
|
||||
health_check_interval=self.config.get('data_collection', {}).get('health_check_interval', 120.0),
|
||||
store_raw_data=self.config.get('data_collection', {}).get('store_raw_data', True),
|
||||
logger=self.logger,
|
||||
log_errors_only=True
|
||||
log_errors_only=False # Enable full logging temporarily to debug WebSocket issues
|
||||
)
|
||||
|
||||
# Replace the default data processor with our custom one
|
||||
|
||||
@ -58,10 +58,10 @@
|
||||
- [x] 2.0.2 Enhance data collectors with health monitoring, heartbeat system, and auto-restart capabilities
|
||||
- [x] 2.0.3 Create collector manager for supervising multiple data collectors with coordinated lifecycle management
|
||||
- [x] 2.1 Implement OKX WebSocket API connector for real-time data
|
||||
- [ ] 2.2 Create OHLCV candle aggregation logic with multiple timeframes (1m, 5m, 15m, 1h, 4h, 1d)
|
||||
- [ ] 2.3 Build data validation and error handling for market data
|
||||
- [ ] 2.4 Implement Redis channels for real-time data distribution
|
||||
- [ ] 2.5 Create data storage layer for OHLCV data in PostgreSQL
|
||||
- [x] 2.2 Create OHLCV candle aggregation logic with multiple timeframes (1m, 5m, 15m, 1h, 4h, 1d)
|
||||
- [x] 2.3 Build data validation and error handling for market data
|
||||
- [x] 2.4 Implement Redis channels for real-time data distribution
|
||||
- [x] 2.5 Create data storage layer for OHLCV data in PostgreSQL
|
||||
- [ ] 2.6 Add technical indicators calculation (SMA, EMA, RSI, MACD, Bollinger Bands)
|
||||
- [ ] 2.7 Implement data recovery and reconnection logic for API failures
|
||||
- [ ] 2.8 Create data collection service with proper logging
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user