Skip to content

feat(backend): implement granular metrics tracking for Multi-currency Exchange Rate Service#1260

Merged
emdevelopa merged 2 commits into
emdevelopa:mainfrom
barry01-hash:feature/be-implement-granular-metrics-tracking-for-multi-currency-exchange-rate-service
Jul 26, 2026
Merged

feat(backend): implement granular metrics tracking for Multi-currency Exchange Rate Service#1260
emdevelopa merged 2 commits into
emdevelopa:mainfrom
barry01-hash:feature/be-implement-granular-metrics-tracking-for-multi-currency-exchange-rate-service

Conversation

@barry01-hash

@barry01-hash barry01-hash commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Closes #1118

Summary

Adds granular Prometheus metrics tracking for the Multi-currency Exchange Rate Service (path payment quote endpoint), providing observability into quote request volume, latency, asset pair distribution, Horizon API call health, and slippage application.

Closes #[issue_id]

New Metrics

Exchange Rate Quote Requests (exchange_rate_quote_requests_total)

Counter with labels: source_asset, dest_asset, result (success, not_found, error, rate_limited, same_asset, not_pending)

  • Recorded at the route handler level for all request outcomes
  • Also recorded at the findStrictReceivePaths function level for Horizon call results

Exchange Rate Quote Duration (exchange_rate_quote_duration_seconds)

Histogram with labels: source_asset, dest_asset, result
Buckets: 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10 seconds

  • Captures end-to-end latency for quote resolution

Exchange Rate Horizon Calls (exchange_rate_horizon_calls_total)

Counter with labels: operation (strict_receive_paths, load_account), status (success, error)

  • Tracks Horizon API call health for the exchange rate service

Exchange Rate Source Account Validation (exchange_rate_source_account_validation_total)

Counter with labels: result (valid, not_found, skipped, error)

  • Tracks source account validation outcomes before quote resolution

Exchange Rate Slippage Applied (exchange_rate_slippage_applied_total)

Counter with labels: slippage_pct

  • Tracks how often the 1% slippage buffer is applied to quotes

Files Changed

Modified:

  • backend/src/lib/metrics.js — Added 5 new metric definitions and registration
  • backend/src/lib/stellar.js — Added metrics instrumentation to findStrictReceivePaths()
  • backend/src/routes/payments.js — Added metrics tracking to the GET /api/path-payment-quote/:id route handler

Added:

  • backend/src/lib/metrics.test.js — 6 tests validating metric definition, registration, and Prometheus output format
  • backend/src/lib/stellar-metrics.test.js — 4 tests validating metrics recording for success, not_found, error, and skipped validation paths

Test Results

  • 10 new tests all passing
  • All existing 855 passing tests unchanged
  • 32 pre-existing test failures unchanged (unrelated to this change)

Verification

# Verify metrics are exposed
curl http://localhost:3000/metrics | grep exchange_rate

# Run metrics tests
cd backend && npx vitest run src/lib/metrics.test.js src/lib/stellar-metrics.test.js

@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

@barry01-hash is attempting to deploy a commit to the Emmanuel's projects Team on Vercel.

A member of the Team first needs to authorize it.

…t-granular-metrics-tracking-for-multi-currency-exchange-rate-service

# Conflicts:
#	backend/src/lib/metrics.js
@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@barry01-hash 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! 🚀

Learn more about application limits

@emdevelopa
emdevelopa merged commit f698209 into emdevelopa:main Jul 26, 2026
1 of 4 checks 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.

[Backend] Implement granular metrics tracking for Multi-currency Exchange Rate Service

2 participants