feat: introduce prom client metrics - #2235
Open
bosbaber wants to merge 4 commits into
Open
Conversation
bosbaber
marked this pull request as draft
September 1, 2026 14:37
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds Prometheus-compatible HTTP metrics to the Wallet and Boutique backends by introducing a shared metrics registry, HTTP request instrumentation middleware, and a dedicated /metrics server bound on a separate port. This improves observability for performance and bottleneck investigations across the TestNet services.
Changes:
- Added a shared
@shared/backendmetrics module (registry + HTTP middleware + standalone/metricsserver) with Jest coverage. - Wired metrics registry + HTTP middleware into both Wallet and Boutique backend apps, and started a dedicated metrics server on
METRICS_PORT. - Exposed and configured the metrics port via Helm charts (deployment ports + service ports + configMaps).
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds @prometheus-io/client and new Jest-related deps for shared backend tests. |
| packages/shared/backend/src/middleware/metrics.ts | Introduces metrics registry, HTTP metrics middleware, and a dedicated /metrics server. |
| packages/shared/backend/src/middleware/index.ts | Re-exports metrics utilities from the shared backend middleware barrel. |
| packages/shared/backend/tests/middleware/metrics.test.ts | Adds Jest tests for /metrics endpoint behavior and HTTP middleware labeling. |
| packages/shared/backend/package.json | Adds prom client dependency; switches shared backend to run Jest tests. |
| packages/shared/backend/jest.config.json | Adds Jest config for shared backend TypeScript tests. |
| packages/wallet/backend/src/createContainer.ts | Registers a shared metricsRegistry in the wallet DI container. |
| packages/wallet/backend/src/config/env.ts | Adds METRICS_PORT env var (default 9464). |
| packages/wallet/backend/src/app.ts | Starts a metrics server and installs HTTP metrics middleware in wallet backend. |
| packages/wallet/backend/package.json | Adds @prometheus-io/client dependency to wallet backend. |
| packages/boutique/backend/src/container.ts | Registers a shared metricsRegistry in the boutique DI container. |
| packages/boutique/backend/src/config/env.ts | Adds METRICS_PORT env var (default 9464). |
| packages/boutique/backend/src/app.ts | Starts a metrics server and installs HTTP metrics middleware in boutique backend. |
| packages/boutique/backend/package.json | Adds @prometheus-io/client dependency to boutique backend. |
| helm/testnet-wallet/values.yaml | Adds metricsPort, exposes container/service metrics port, and configures METRICS_PORT. |
| helm/testnet-wallet/tests/services_test.yaml | Validates wallet service includes the metrics port. |
| helm/testnet-wallet/tests/deployment.backend_test.yaml | Validates wallet deployment exposes the metrics port and sets METRICS_PORT. |
| helm/testnet-boutique/values.yaml | Adds metricsPort, exposes container/service metrics port, and configures METRICS_PORT. |
| helm/testnet-boutique/tests/services_test.yaml | Validates boutique service includes the metrics port. |
| helm/testnet-boutique/tests/deployment.backend_test.yaml | Validates boutique deployment exposes the metrics port and sets METRICS_PORT. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
Suppressed comments (1)
packages/shared/backend/tests/middleware/metrics.test.ts:49
- server.address() can return null (before the 'listening' event) or a string, so casting it directly to { port: number } can throw at runtime or be flaky. Wait for 'listening' and assert the address type before reading .port.
it('startMetricsServer 404s on any other path', async (): Promise<void> => {
const register = createMetricsRegistry()
const server = startMetricsServer(register, 0)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
bosbaber
marked this pull request as ready for review
September 1, 2026 15:04
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.
Context
We have a problem where are really struggle to understand the reason of performance bottlenecks. This is especially true whenever the wallet appears unexpectedly slow.
This pull request adds Prometheus-compatible HTTP metrics to both the Boutique and Wallet backend services, enabling improved observability and monitoring. It introduces a new metrics server running on a dedicated port, exposes metrics via a
/metricsendpoint, and integrates middleware to collect HTTP request metrics. The changes are thoroughly tested and configurable via Helm charts and environment variables.