Skip to content

Add CloudWatch log aggregation and correlation IDs#109

Open
Obiajulu-gif wants to merge 1 commit intoMissBlue00:mainfrom
Obiajulu-gif:configure_log_aggregation
Open

Add CloudWatch log aggregation and correlation IDs#109
Obiajulu-gif wants to merge 1 commit intoMissBlue00:mainfrom
Obiajulu-gif:configure_log_aggregation

Conversation

@Obiajulu-gif
Copy link
Copy Markdown

This pull request introduces a comprehensive observability and structured logging system for the stellar-pay API service. It adds structured JSON logging with correlation IDs, integrates request and exception logging throughout the application, and provides supporting middleware and utilities for request context propagation. Additionally, it includes environment variable configuration and documentation for observability, as well as a CloudWatch dashboard deployment script.

Observability and Structured Logging

  • Introduced a structured JSON logger (StructuredLogger) that emits logs with correlation IDs, environment, and contextual metadata, and supports hierarchical child loggers for per-controller/service logging. Added comprehensive unit tests for the logger. (apps/api/src/observability/logger.ts, apps/api/src/observability/logger.spec.ts) [1] [2]
  • Implemented a request context propagation system using AsyncLocalStorage to track correlation IDs and request metadata throughout the lifecycle of each request. Added a middleware (RequestContextMiddleware) to assign/generate correlation IDs and propagate context, and exposed context utilities. (apps/api/src/observability/request-context.ts, apps/api/src/observability/request-context.middleware.ts) [1] [2]

Request and Exception Logging

  • Added a global request logging interceptor (RequestLoggingInterceptor) to log all HTTP requests and responses, including status, duration, user, and correlation IDs. Integrated a global exception filter (LoggingExceptionFilter) to log unhandled exceptions with full context and return correlation IDs in error responses. (apps/api/src/observability/request-logging.interceptor.ts, apps/api/src/observability/logging-exception.filter.ts, apps/api/src/main.ts) [1] [2] [3]
  • Refactored controllers and services to use contextual child loggers for structured event logging at key points (e.g., endpoint requests, health checks, treasury operations). (apps/api/src/app.controller.ts, apps/api/src/app.service.ts, apps/api/src/health/health.controller.ts, apps/api/src/treasury/treasury.controller.ts, apps/api/src/treasury/treasury.service.ts) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

Configuration and Documentation

  • Added environment variables for log level and CloudWatch integration in .env.example, and documented observability features and deployment instructions in the project README. Provided a script and documentation for provisioning CloudWatch dashboards, metric filters, and alarms. (apps/api/.env.example, stellar-pay/README.md) [1] [2]

Supporting Codebase Changes

  • Registered the new middleware and observability utilities in the application module and created a central export barrel for observability components. (apps/api/src/app.module.ts, apps/api/src/observability/index.ts) [1] [2] [3] [4]

Closes #97

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 24, 2026

@Obiajulu-gif is attempting to deploy a commit to the missblue00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 24, 2026

@Obiajulu-gif 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! 🚀

Learn more about application limits

@MissBlue00
Copy link
Copy Markdown
Owner

@binayyub4211 the ci/cd checks failed and there are merge conflicts, please resolve

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.

Configure log aggregation with ELK/CloudWatch

2 participants