Skip to content

Commit 694f8ec

Browse files
committed
feat(graph-proxy): add counter for errors in query and mutation
1 parent 38c0cb9 commit 694f8ec

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

backend/graph-proxy/src/graphql/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ pub async fn graphql_handler(
165165
} else {
166166
"error"
167167
};
168+
if status == "error" {
169+
state
170+
.metrics_state
171+
.total_errors
172+
.add(1, &[KeyValue::new("status", "error")]);
173+
};
168174
state.metrics_state.request_duration_ms.record(
169175
elapsed_ms,
170176
&[

backend/graph-proxy/src/metrics.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ pub struct Metrics {
1313
pub total_requests: Counter<u64>,
1414
/// Request duration in miliseconds on every request
1515
pub request_duration_ms: Histogram<f64>,
16+
/// Total errors on querys and mutations
17+
pub total_errors: Counter<u64>,
1618
}
1719

1820
impl Metrics {
@@ -31,9 +33,15 @@ impl Metrics {
3133
.with_unit("ms")
3234
.build();
3335

36+
let total_errors = meter
37+
.u64_counter("graph_proxy_total_errors")
38+
.with_description("The total errors on all querys and mutations.")
39+
.build();
40+
3441
Metrics {
3542
total_requests,
3643
request_duration_ms,
44+
total_errors,
3745
}
3846
}
3947
}

0 commit comments

Comments
 (0)