feat(api): Add Prometheus metrics endpoint (issue #219)#282
Merged
Xhristin3 merged 2 commits intoJun 17, 2026
Merged
Conversation
- Install prom-client@15.1.3 - Add MetricsService with Registry, counters, histogram, and gauge - Add MetricsController exposing GET /metrics in Prometheus text format - Add MetricsModule exporting MetricsService - Register collectDefaultMetrics for Node.js process/GC/heap metrics - Track http_requests_total and http_request_duration_seconds in RequestLoggerMiddleware - Track websocket_connections_total and websocket_active_connections in StreamsGateway - Import MetricsModule in AppModule and GatewaysModule - Add unit tests: metrics.service.spec.ts, metrics.controller.spec.ts - All 21 tests pass, TypeScript clean, ESLint clean Closes XStreamRollz#219
Xhristin3
approved these changes
Jun 17, 2026
Xhristin3
left a comment
Contributor
There was a problem hiding this comment.
Love the clean separation — metrics module isolated from app code, /metrics excluded from request logging so we don't pollute our own data, and tests cover gauges + counters. LGTM, merging 🎉
5 tasks
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.
Summary
Closes #219
Adds a Prometheus-compatible
GET /metricsendpoint to the NestJS API, providing full production observability.Changes
New files
api/src/metrics/metrics.service.ts—MetricsServicewraps a dedicatedprom-clientRegistryand exposes:http_requests_total(Counter, labels: method/path/status_code)http_request_duration_seconds(Histogram, 10-bucket, same labels)websocket_connections_total(Counter)websocket_active_connections(Gauge)collectDefaultMetricsapi/src/metrics/metrics.controller.ts—GET /metricsreturns Prometheus text format with correctContent-Typeapi/src/metrics/metrics.module.ts— NestJS module exportingMetricsServiceapi/src/metrics/metrics.service.spec.ts— unit tests for all counters, histogram, gauge, and default metricsapi/src/metrics/metrics.controller.spec.ts— unit tests for response headers and bodyModified files
api/package.json— addprom-client@15.1.3,@nestjs/testing@10.3.0(devDep)api/src/app.module.ts— importMetricsModuleapi/src/gateways/gateways.module.ts— importMetricsModulesoStreamsGatewaycan injectMetricsServiceapi/src/gateways/streams.gateway.ts— injectMetricsService(optional) and track WS connect/disconnectapi/src/middleware/request-logger.middleware.ts— injectMetricsService(optional) and record HTTP counters/histogram on response finishAcceptance criteria
Testing