Skip to content

Add FX rate staleness monitoring and admin visibility - #443

Merged
therealjhay merged 4 commits into
Betta-Pay:mainfrom
afeezorobsco-cyber:feat/fx-rate-staleness-monitoring
Jul 30, 2026
Merged

Add FX rate staleness monitoring and admin visibility#443
therealjhay merged 4 commits into
Betta-Pay:mainfrom
afeezorobsco-cyber:feat/fx-rate-staleness-monitoring

Conversation

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

##close #332

Summary

This PR adds observability for stale FX rates by introducing configurable staleness thresholds, structured logging, and per-currency-pair staleness reporting in the admin status endpoint.

Changes

Configuration

Added a new environment variable:

Variable Default Description
MAX_STALE_SECONDS 300 Maximum acceptable age of a served FX rate before it is considered stale.

Staleness Monitoring

When serving a rate:

  • Calculates the rate age in seconds.
  • Compares it with MAX_STALE_SECONDS.

Logging behaviour:

  • Fresh rate → no additional log.
  • Stale live rate → structured WARN log.
  • Stale seed/fallback rate → structured ERROR log.

The change is observational only and does not alter pricing or request handling.

Admin Status

Extended the admin status endpoint to expose per-currency-pair staleness, including:

  • Currency pair
  • Rate source
  • Last update timestamp
  • stalenessSeconds
  • stale flag

Testing

Added coverage for:

  • ✅ Fresh rate (no warning).
  • ✅ Stale live rate (WARN).
  • ✅ Stale seed rate (ERROR).
  • ✅ Boundary at MAX_STALE_SECONDS.
  • ✅ Correct staleness values in the admin status endpoint.

Verification

Executed:

npm test
npm run lint
npm run build

Verified that:

  • Fresh rates do not generate alerts.
  • Stale live rates emit WARN logs.
  • Stale seed/fallback rates emit ERROR logs.
  • The admin status endpoint accurately reports per-pair staleness.
  • Existing FX behaviour remains unchanged.

Closes #

@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@afeezorobsco-cyber 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

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor Author

@therealjhay pls review and merge

@therealjhay
therealjhay merged commit a34260a into Betta-Pay:main Jul 30, 2026
0 of 2 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.

Add staleness detection and alert logging for FX rates

2 participants