feat(#593): Add comprehensive Prometheus metrics collection#742
Merged
RUKAYAT-CODER merged 2 commits intoJun 1, 2026
Merged
Conversation
- Expose GET /metrics endpoint via PrometheusController with optional
bearer-token authentication (METRICS_AUTH_TOKEN env var)
- Add HttpMetricsMiddleware to auto-record HTTP request durations and
5xx error counts with cardinality-safe route normalisation
- Add DbMetricsSubscriber (TypeORM EntitySubscriber) to record per-query
execution times into db_query_duration_seconds histogram
- Add DbPoolMetricsCollector (scheduled every 10 s) to push pg pool
stats (size, idle, pending, active) into Prometheus gauges
- Enhance MetricsCollectionService with full metric set:
* Infrastructure: http_request_duration_seconds,
db_query_duration_seconds, db_active_connections,
db_pool_size / idle / pending / acquired / released
* Business: user_registrations_total, active_users,
course_enrollments_total, course_completion_rate_percentage,
assessment_completions_total, learning_path_progress_percentage,
payment_transactions_total, cache_hit_rate_percentage,
queue_processing_duration_seconds, email_campaigns_sent_total,
backup_operations_total, api_errors_total
- Wire all new providers and controller into MonitoringModule
- Document METRICS_ENABLED / METRICS_AUTH_TOKEN / METRICS_PATH in
.env.example
- Add 16 unit tests (prometheus.controller.spec.ts,
http-metrics.middleware.spec.ts) – all passing
Closes rinafcode#593
|
@amankoli09 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! 🚀 |
Contributor
|
kindly resolve conflict and fix workflow. |
… keep Prometheus metrics infrastructure with CommonModule
Contributor
Author
|
@RUKAYAT-CODER I have fixed the changes. Please have a look to it if any changes to be made, just text me. Sorry for the inconvenience. |
Contributor
|
Thank you for contributing to the project. |
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.
Closes #593
Summary
Type of change
Pre-merge checklist (required)
Branch & metadata
feature/issue-<N>-<slug>/fix/issue-<N>-<slug>conventiondevelopormain)Code quality & tests
npm run lint:ci— zero ESLint warningsnpm run format:check— Prettier reports no changes needednpm run typecheck— zero TypeScript errorsnpm run test:ci— all tests pass, coverage ≥ 70%.spec.tsunit testsError handling & NestJS best practices
class-validator/class-transformerdecorators and are wired through NestJS pipes (e.g. globalValidationPipeor explicit)any/unknownreaching the domain)BadRequestException,UnauthorizedException,ForbiddenException,NotFoundException) instead of genericErrorLoggeror central logger service) with meaningful, structured messagesAuthGuard, role/permissions guards, custom guards) are applied to all new/modified endpoints where appropriateAPI documentation / Swagger
/api(or Swagger UI) reflects new/changed endpoints correctlyBreaking changes
Breaking change description (if applicable)
Test evidence (required)
Commands run locally
Manual / API verification