Skip to content

V2 metrics enhancement#1681

Draft
benalleng wants to merge 3 commits into
payjoin:masterfrom
benalleng:v2_metrics_enhancement
Draft

V2 metrics enhancement#1681
benalleng wants to merge 3 commits into
payjoin:masterfrom
benalleng:v2_metrics_enhancement

Conversation

@benalleng

@benalleng benalleng commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

This PR is vibed to address an out of band observation that the mailroom did not properly find v2 /{mailbox} endpoints even following our latest update to the metrics.

I pushed a branch to the upstream repo so I could easily test the mailroom metrics on https://pj.benalleng.com. I can confirm that the /{mailbox} endpoint is when using this branch.

Coded with Glm 5.2

Pull Request Checklist

Please confirm the following before requesting review:

@coveralls

coveralls commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 28179458288

Coverage increased (+0.2%) to 85.676%

Details

  • Coverage increased (+0.2%) from the base build.
  • Patch coverage: 14 uncovered changes across 1 file (190 of 204 lines covered, 93.14%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
payjoin-mailroom/src/directory.rs 187 173 92.51%
Total (4 files) 204 190 93.14%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15303
Covered Lines: 13111
Line Coverage: 85.68%
Coverage Strength: 358.02 hits per line

💛 - Coveralls

The outer track_metrics middleware only sees the wire path
(/.well-known/ohttp-gateway or /), so V2 mailbox traffic was
invisible to per-endpoint counters. handle_decapsulated_request
now records each logical V2 operation (POST/GET/PUT) using the
same endpoint_label/method_label collapse used at the outer layer.

HandlerError gains a side-effect-free status_code() helper so the
inner record can read the status without running to_response's
logging twice.
A successful V2 request is now counted twice: once at the outer
middleware boundary (every byte on the socket) and once after OHTTP
decapsulation (the logical V2 op it carried). The bounded
RequestLayer enum (gateway | v2) keeps the two counts
distinguishable so dashboards can pick one.
Adds three tests for handle_decapsulated_request's metric
recordings: POST happy path (layer=v2, endpoint=/{mailbox},
method=POST, status=200), GET timeout (status=202), and the
catch-all 404 arm (endpoint=other). Also guards that the actual
short-id value never reaches any metric label.

test_service delegates to test_service_with_metrics so tests can
inject a provider-backed MetricsService.
@benalleng benalleng force-pushed the v2_metrics_enhancement branch from b1dc4e5 to 302175f Compare June 25, 2026 14:59
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