Skip to content

feat(metrics): treasury USDT balance gauge (ENG-485 part 2)#437

Merged
islandbitcoin merged 1 commit into
mainfrom
jabariennis/eng-485-treasury-gauge
Jul 7, 2026
Merged

feat(metrics): treasury USDT balance gauge (ENG-485 part 2)#437
islandbitcoin merged 1 commit into
mainfrom
jabariennis/eng-485-treasury-gauge

Conversation

@islandbitcoin

Copy link
Copy Markdown
Contributor

Summary

Adds a treasury_usdt_balance Prometheus gauge. The existing funder gauge tracks the funder's default wallet (BTC); the cutover treasury is the funder's USDT wallet (resolved by currency, ENG-482), so treasury drain during a cutover run — fee reimbursements, rollback top-ups — was invisible to metrics. Resolver mirrors the cutover treasury logic; when the treasury isn't provisioned (prod pre-cutover) it throws and the gauge's existing cache-fallback path handles it (no report until the wallet exists).

Part 1 (httpCode) deliberately excluded — upstream-blocked

The ticket's premise (uncomment httpCode = err instanceof ApiError ? err.code) doesn't work: the ibex-client ApiError constructor is super(e.stack) — it discards the original error's status entirely. There is no .code; uncommenting would set httpCode = undefined always. Structural === 429 detection requires an upstream ibex-client change (or parsing status text out of the message). Full finding on ENG-485.

Test plan

  • tsc + eslint clean
  • Resolver mirrors the cutover treasury resolver, which is unit-tested in runtime-services.spec.ts. The exporter itself has no unit harness (server bootstrap); the gauge machinery + cache-fallback are pre-existing and battle-tested.

Refs ENG-485

🤖 Generated with Claude Code

The `funder` gauge tracks the funder's DEFAULT wallet (BTC). The cutover
treasury is the funder's USDT wallet (resolved by currency, ENG-482), so
treasury drain during a cutover run — fee reimbursements, rollback
top-ups — is invisible to metrics and alerts. Adds a `treasury_usdt`
wallet gauge resolving the funder's USDT wallet, mirroring the cutover
treasury resolver. When the treasury isn't provisioned yet (prod
pre-cutover) the resolver throws and the gauge's existing cache-fallback
path handles it — it simply doesn't report until the wallet exists.

Part 1 (IbexError httpCode propagation) is NOT included — see ENG-485:
the ibex-client ApiError constructor does `super(e.stack)`, discarding
the original error's status entirely, so httpCode cannot be propagated
without an upstream ibex-client change. Documented on the ticket.

Refs ENG-485

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@linear

linear Bot commented Jul 7, 2026

Copy link
Copy Markdown

ENG-485

@islandbitcoin islandbitcoin merged commit f6aae8d into main Jul 7, 2026
14 checks passed
@islandbitcoin islandbitcoin deleted the jabariennis/eng-485-treasury-gauge branch July 7, 2026 12:38
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.

2 participants