Skip to content

Realtime server: no structured logging, no error categorization, no monitoring #34

@jasonli2446

Description

@jasonli2446

Problem

The realtime server uses console.log / console.error for all logging. In production, this makes debugging and monitoring difficult.

Current State

  • All events logged with console.log (connection, disconnection, room lifecycle)
  • All errors logged with console.error (generic message + error)
  • No structured format (JSON)
  • No log levels (debug, info, warn, error)
  • No request correlation IDs
  • No error categorization (auth vs network vs protocol)
  • No metrics collection

What's Needed

  1. Structured logging — JSON format with timestamp, level, context
  2. Error categorization — Distinguish auth errors, network errors, protocol errors, internal errors
  3. Correlation IDs — Track operations across socket events
  4. Health metrics — Room count, peer count, producer/consumer count, memory usage
  5. Log library — Consider pino or winston for structured logging

Also Missing

  • No io.on("error") or io.on("connection_error") handler on the Socket.IO server
  • Connection errors are silently lost

Acceptance Criteria

  • Replace console.log/error with structured logging library
  • Add log levels and error categorization
  • Add Socket.IO error event handlers
  • Add basic metrics (room/peer counts) to health endpoint
  • Add correlation IDs for operation tracking

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestlowLow priorityrealtimeRealtime/WebRTC/Socket.IO

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions