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, } } }