feat(x402): add last-payment-success-seconds gauge + recording rule for settlement log#550
Open
bussyjd wants to merge 1 commit into
Open
feat(x402): add last-payment-success-seconds gauge + recording rule for settlement log#550bussyjd wants to merge 1 commit into
bussyjd wants to merge 1 commit into
Conversation
…or settlement log The `obol_x402_verifier_last_payment_success_seconds` gauge already lands on the verifier success branch (see internal/x402/verifier.go:206 and :261, right next to chargedRequests.Inc()). Add the matching recording rule so the frontend My Purchases drawer can render "last settlement: 12s ago" labels without joining against the buyer sidecar or chasing receipts.
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The My Purchases chevron drawer in the frontend currently shows:
That's a self-spec. The gauge already lands on the verifier success branch (
internal/x402/verifier.go:206and:261, right next tochargedRequests.With(labels).Inc()), registered alongside the existing counters ininternal/x402/metrics.goand tested ininternal/x402/verifier_test.go. The missing piece — and the only change in this PR — is the matching Prometheus recording rule so the frontend can query age-since-last-settlement without joining against the buyer sidecar or scraping on-chain receipts.Schema
obol_x402_verifier_last_payment_success_secondsoffer_namespace,offer_name,chain,asset_symbol(matchesprometheusLabels())SetToCurrentTime()in the same success branch that bumpsobol_x402_verifier_charged_requests_total. Already gated bypruneSeriesNotInso deleted offers stop emitting stale timestamps.Recording rule
Added to
x402.recordinggroup ininternal/embed/infrastructure/base/templates/x402-prometheus-rules.yaml:Rationale
clamp_min/ no constant floor. Until an offer settles at least once, the gauge has no series for it —max(...)returns no samples and the recorded series is simply absent for that offer. The frontend renders "no settlements yet" instead of a misleading "X seconds since 1970".time() - max(gauge), so a single counter.Inc()plus one gauge.Set(now)keeps the per-request hot path cheap (no per-request timer math at scrape time).max by (...)collapses asset_symbol — a single(offer, chain)almost always pins one asset, butmaxis safe even if a route re-pins (USDC -> OBOL) because the most recent settlement wins.Test plan
go build ./...— cleango test ./internal/x402/... ./internal/serviceoffercontroller/...— pass (existingverifier_test.gocovers the gauge wiring at lines 880-979 and the prune semantics at 1016-1053)helm-template-smoke.ymlflow locally withOLLAMA_HOST_IP=127.0.0.1,CLUSTER_ID=ci-helm-smoke,dataDir=/data,network=mainnet) — renders cleanly, new recording rule appears in the rendered output verbatimhelm lintstand-in — cleanFrontend follow-up
Paired PR in
obol-stack-front-endwill queryx402:last_payment_age_seconds:by_offer_chainand render the My Purchases settlement table off the recorded series. No more "wire one of these two metrics" placeholder copy.Do NOT merge — human review required per
feedback_main_merge_gates.md.