Skip to content

feat: introduce prom client metrics - #2235

Open
bosbaber wants to merge 4 commits into
mainfrom
stephan/20260901-introduce-metrics
Open

feat: introduce prom client metrics#2235
bosbaber wants to merge 4 commits into
mainfrom
stephan/20260901-introduce-metrics

Conversation

@bosbaber

@bosbaber bosbaber commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

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 /metrics endpoint, and integrates middleware to collect HTTP request metrics. The changes are thoroughly tested and configurable via Helm charts and environment variables.

@bosbaber
bosbaber marked this pull request as draft September 1, 2026 14:37
@bosbaber
bosbaber requested a lite review from Copilot September 1, 2026 14:37
@github-actions github-actions Bot added package: wallet/backend Wallet backend implementations type: test Improvements or additions to tests type: source Source changes package: boutique/backend Boutique backend implementations labels Sep 1, 2026
@bosbaber bosbaber self-assigned this Sep 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/backend metrics module (registry + HTTP middleware + standalone /metrics server) 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.

Comment thread packages/boutique/backend/src/config/env.ts
Comment thread packages/shared/backend/src/middleware/metrics.ts
Comment thread packages/shared/backend/tests/middleware/metrics.test.ts
@bosbaber
bosbaber marked this pull request as ready for review September 1, 2026 15:04
@bosbaber
bosbaber requested a review from dragosp1011 September 1, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: boutique/backend Boutique backend implementations package: wallet/backend Wallet backend implementations type: source Source changes type: test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants