feat: add structured logging to the intents WebSocket gateway - #167
Open
Paranoa-dev wants to merge 2 commits into
Open
feat: add structured logging to the intents WebSocket gateway#167Paranoa-dev wants to merge 2 commits into
Paranoa-dev wants to merge 2 commits into
Conversation
- Add periodic ping/pong heartbeat to IntentsGateway using the standard ws library pattern - Track alive status per client with a WeakMap - Every 30s, mark all clients as 'not alive', send ping; clients that respond with pong are marked alive again; those that don't are terminated and removed from the subscriber set - Implement OnModuleDestroy to clean up the heartbeat interval - Add unit tests for heartbeat behavior (alive marking, pong response, dead client termination, interval cleanup) - Fix e2e config for pre-existing test environment issues Closes stellar-vortex-protocol#81
|
@Paranoa-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Structured Logging for WebSocket Events
Summary
This PR adds structured logging to
IntentsGatewayusing the shared winston logger fromsrc/common/logger.ts, providing operators with visibility into WebSocket activity that was previously silent.Problem
The WebSocket gateway had zero logging — connects, disconnects, and broadcasts happened silently. Unlike HTTP requests (logged via
LoggingInterceptor), there was no way to observe WS activity in production logs.Changes
src/intents/intents.gateway.tsloggerfromsrc/common/logger.tsws client connected (subscribers=N)on each new connection, showing the current subscriber countws client disconnected (subscribers=N)on each disconnectws broadcast type=<eventType> subscribers=Nat debug level for every broadcast — captures event type only (not payload) to avoid log volume blowupws heartbeat startedon gateway construction, andws heartbeat terminated dead client (subscribers=N)when a dead client is cleaned upgetSubscriberCount(): Exposes the raw subscriber count (separate from the existinggetAliveCount()which only counts clients that responded to the last ping)src/intents/intents.gateway.spec.tsAdded a new
IntentsGateway loggingtest suite with 5 tests verifying:Log Format
All logs follow the existing winston format:
ISO_TIMESTAMP [level] messageDesign Decisions
intent_created) but not the full payload, to prevent log volume blowup with large intent objectsdebuglevel (only visible in non-production), while connect/disconnect useinfolevel for production visibilityTest Results
Checklist
src/common/logger.tsnpm run lintpassesnpm run typecheckpassesnpm testpassesnpm run test:e2epassesCloses #82