From df3ca81e5523851dcfbd59bcdfdbada3ff10312d Mon Sep 17 00:00:00 2001 From: Sze Ching Date: Mon, 2 Feb 2026 16:34:14 +0000 Subject: [PATCH] feat(graph-proxy): add counter for errors in query and mutation --- backend/graph-proxy/src/graphql/mod.rs | 6 ++++++ backend/graph-proxy/src/metrics.rs | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/backend/graph-proxy/src/graphql/mod.rs b/backend/graph-proxy/src/graphql/mod.rs index aa8c068cd..e996eeb61 100644 --- a/backend/graph-proxy/src/graphql/mod.rs +++ b/backend/graph-proxy/src/graphql/mod.rs @@ -165,6 +165,12 @@ pub async fn graphql_handler( } else { "error" }; + if status == "error" { + state + .metrics_state + .total_errors + .add(1, &[KeyValue::new("status", "error")]); + }; state.metrics_state.request_duration_ms.record( elapsed_ms, &[ diff --git a/backend/graph-proxy/src/metrics.rs b/backend/graph-proxy/src/metrics.rs index 458fc38d7..c65e4430c 100644 --- a/backend/graph-proxy/src/metrics.rs +++ b/backend/graph-proxy/src/metrics.rs @@ -13,6 +13,8 @@ pub struct Metrics { pub total_requests: Counter, /// Request duration in miliseconds on every request pub request_duration_ms: Histogram, + /// Total errors on querys and mutations + pub total_errors: Counter, } impl Metrics { @@ -31,9 +33,15 @@ impl Metrics { .with_unit("ms") .build(); + let total_errors = meter + .u64_counter("graph_proxy_total_errors") + .with_description("The total errors on all querys and mutations.") + .build(); + Metrics { total_requests, request_duration_ms, + total_errors, } } }