Skip to content

- feat(logging): implement structured logging, metrics, and error mon…#69

Closed
Cedarich wants to merge 2 commits into
MettaChain:mainfrom
Cedarich:feature/comprehensive-logging-monitoring
Closed

- feat(logging): implement structured logging, metrics, and error mon…#69
Cedarich wants to merge 2 commits into
MettaChain:mainfrom
Cedarich:feature/comprehensive-logging-monitoring

Conversation

@Cedarich
Copy link
Copy Markdown
Contributor

@Cedarich Cedarich commented Feb 22, 2026

Closes #44


Summary

Implement comprehensive logging and monitoring across the PropChain backend to improve observability, debuggability, and production readiness.

Changes

  • Implement structured logging with correlation and trace IDs

    • Use CLS-based context for correlationId and traceId
    • Attach x-correlation-id and x-trace-id headers in LoggingMiddleware
    • Ensure all logs include correlation/trace IDs via StructuredLoggerService
  • Add log aggregation, centralization, and rotation

    • Centralize Winston configuration with JSON logs and sensitive data redaction
    • Configure console + daily-rotated file transports for error and application logs
    • Define rotation and retention (maxFiles, maxSize, zipped archives)
  • Implement performance monitoring and metrics

    • Introduce MetricsService to track HTTP request counts, durations, and status codes
    • Wire metrics into the HTTP LoggingInterceptor
    • Expose GET /health/metrics for metrics snapshot
  • Add error tracking and alerting hooks

    • Add ErrorMonitoringService as a central place to capture exceptions
    • Update AllExceptionsFilter to:
      • Use structured logging with request/correlation/trace IDs
      • Record error metrics
      • Provide a single integration point for future alerting (Slack/email/etc.)
  • Implement lightweight distributed tracing

    • Manage traceId alongside correlationId in the CLS namespace
    • Propagate x-correlation-id and x-trace-id to outbound valuation API calls
    • Include trace context in all logs for easier end-to-end correlation
  • Integrate logging and monitoring globally

    • Make LoggingModule global and export logger/metrics/error-monitoring services
    • Register LoggingInterceptor and AllExceptionsFilter as global providers
    • Use StructuredLoggerService as the Nest logger in main.ts

Acceptance Criteria Mapping

  • Implement structured logging with correlation IDs
  • Add log aggregation and centralization
  • Implement performance monitoring and metrics
  • Add error tracking and alerting hooks (integration point ready)
  • Implement distributed tracing (correlation/trace IDs + propagation)
  • Add log retention and rotation policies

Notes

  • npm run lint passes (TypeScript version warning only).
  • npm run test:unit currently fails due to Jest coverageThreshold JSON parsing (pre-existing quoting issue on Windows).

close issue #44

@Cedarich
Copy link
Copy Markdown
Contributor Author

Please approve workflow

@LaGodxy
Copy link
Copy Markdown
Contributor

LaGodxy commented Feb 22, 2026

@Cedarich fix CI

@Cedarich Cedarich closed this by deleting the head repository Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Comprehensive Logging and Monitoring

3 participants