Skip to content

feat: expand prometheus http metrics#235

Open
pq198363-ops wants to merge 1 commit into
Agentpay-Org:mainfrom
pq198363-ops:bounty-38-prometheus-metrics
Open

feat: expand prometheus http metrics#235
pq198363-ops wants to merge 1 commit into
Agentpay-Org:mainfrom
pq198363-ops:bounty-38-prometheus-metrics

Conversation

@pq198363-ops

Copy link
Copy Markdown

Closes #38.

Summary

  • add agentpay_http_requests_total{method,route,status} counters for completed HTTP responses
  • add agentpay_http_request_duration_seconds histogram buckets, sums, and counts
  • add agentpay_http_errors_total{type} increments from the terminal Express error handler
  • keep the existing gauges and Prometheus text exposition format
  • record route labels from matched Express route patterns such as /api/v1/usage/:agent/:serviceId, using unmatched for parser failures and unknown routes to avoid raw-path cardinality
  • document all metrics in docs/metrics.md

RED evidence

Before implementation, the focused metrics test failed because /api/v1/metrics only exposed the existing gauges and did not include:

  • agentpay_http_requests_total
  • agentpay_http_request_duration_seconds
  • route-pattern labels for dynamic usage reads
  • agentpay_http_errors_total for terminal error-handler paths

Verification

  • npx prettier --check README.md docs/metrics.md src/metrics.ts src/metrics.test.ts src/middleware/index.ts src/routes/metrics.ts src/routes/errors.ts
  • npm run lint
  • clean dist/, then npm run build
  • $env:NODE_ENV='test'; node --test dist/*.test.js dist/**/*.test.js
  • git diff --check

Full clean test result: 92 tests, 11 suites, all passed.

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.

Expand Prometheus metrics with request latency histograms and error counters

1 participant