404Dev: GraphQL API, Prometheus & New Threading

โœจ NEW FEATURES

๐ŸŽฏ GraphQL API

  • Full GraphQL support using Strawberry GraphQL
  • Endpoint: POST /api/v2/graphql
  • Queries: userTime, clockStatus, leaderboard, insights, systemHealth
  • Mutations: clockIn, clockOut
  • Interactive playground at /api/v2/graphql

๐Ÿ“Š Prometheus Metrics & Monitoring

  • 50+ metrics for comprehensive observability
  • Metrics endpoint: GET /metrics (Prometheus text format)
  • Categories tracked:
  • API requests (count, duration, size, in-flight)
  • Authentication (attempts, rate limits, active keys)
  • Database (Redis/PostgreSQL operations, connection pools)
  • Cache (hit/miss rates, sizes, evictions per layer)
  • Threading (workers, queue size, lock contention)
  • Business (active sessions, clock ops, WebSocket connections)
  • Batch processing (operations, sizes, durations)

๐Ÿฅ Enhanced Health Checks

  • Basic health: GET /health - Simple up/down status
  • Detailed health: GET /health/detailed - Full system diagnostics
  • Thread pool status (active workers, queue size)
  • Redis connection status
  • PostgreSQL pool usage and database size
  • Active sessions count
  • Cache sizes (L1, L2, L3)
  • Circuit breaker metrics

๐Ÿ”’ Thread-Safe Atomic Operations

  • New module: Utils/atomic_operations.py
  • Decorators: @atomic_redis, @atomic_db, @atomic_cache
  • Batch processor: AtomicBatchProcessor for efficient bulk operations
  • Context managers: AtomicRedisContext, AtomicDBContext
  • Metrics integration: Automatic lock wait time tracking
  • Thread-safe singleton: Base class for shared resources

๐Ÿงต Threading Model

  • API in separate thread with its own asyncio event loop
  • Thread pool: 4 workers for batch processing
  • No bot interference: API operations don't block Discord bot
  • Better CPU utilization: Multi-core usage
  • Daemon thread: Automatic cleanup on bot shutdown

๐ŸŽจ Enhanced API Documentation

  • Swagger UI improvements:
  • Search/filter enabled
  • Request duration display
  • Deep linking (shareable URLs)
  • Monokai dark theme
  • Persistent authorization
  • Auto-collapsed models
  • GraphQL Playground: Interactive GraphQL IDE
  • ReDoc: Alternative documentation view

The latest from 404Development | Software Hub