feat(metrics): add HTTP request and payment settlement metrics - #207
Open
Hahfyeex wants to merge 3 commits into
Open
feat(metrics): add HTTP request and payment settlement metrics#207Hahfyeex wants to merge 3 commits into
Hahfyeex wants to merge 3 commits into
Conversation
…#144) WEBHOOK_REDRIVE_GRACE_SECS was a flat idle window, not the bounded exponential backoff TODO.md Step 6 called for. Add WEBHOOK_REDRIVE_BACKOFF_INITIAL_SECS / _MAX_SECS: a delivery that has failed at least once now waits initial * 2^(attempts-1), capped at max, before the redrive worker retries it. grace_secs remains a floor so a row never touched (crash before its first send) isn't penalized. Also repairs the build, which was broken on main: a bad merge (13b49a2) duplicated the shutdown join_task! calls in main.rs, and main.rs/expiry.rs's test fixture were missing the task_health field added by an earlier PR.
auth_middleware returned 401 for missing/invalid keys with no structured
log, so credential-stuffing or a misconfigured client was invisible.
Every outcome (missing key, invalid key, lookup error, success) is now
logged with source_ip + reason at a level matched to severity, and
counted via a new AuthMetrics exposed on GET /metrics as
stellargate_auth_attempts_total{outcome,reason}, mirroring the existing
WebhookMetrics pattern.
…arGateLabs#133) /metrics only exposed webhook delivery and auth outcome counters; operators had no way to see request throughput/error rates or settlement latency without parsing logs. Adds RequestMetrics (counted by matched route template, method, and status — not raw path, to keep cardinality bounded — plus a latency histogram) wired as the outermost middleware layer so it captures the final status including 408s from the timeout layer, and SettlementMetrics (completed/overpaid/underpaid/expired counters plus a created-to-settled latency histogram) recorded at the two points a payment reaches a terminal state: horizon::settle() and expiry::sweep_once(). Moves the `time` crate from dev- to regular dependencies to compute settlement latency from stored RFC 3339 timestamps.
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.
Summary
timecrate from dev- to regular dependencies to compute settlement latency from the stored RFC 3339 created_at.Closes #133
Note: stacked on #206 (auth logging/metrics) and #205 (redrive backoff config), since it builds on the AuthMetrics render() pattern and the main.rs/task_health build fix from those. Diff will shrink to just this PR's changes as the earlier ones merge.
Test plan