From b558b0d3f1bbc0955630d1d2feb250aa90efd0b0 Mon Sep 17 00:00:00 2001 From: Alex Leong Date: Tue, 3 Oct 2023 17:17:28 -0700 Subject: [PATCH] Render grpc_status metric label as number (#2480) Fixes https://github.com/linkerd/linkerd2/issues/11449 The `grpc_status` metric label is rendered as a long form, human readable string value in the proxy metrics. For example: ``` response_total{direction="outbound", [...], classification="failure",grpc_status="Unknown error",error=""} 1 ``` This is because of the Display impl for Code. We explicitly convert to an i32 so this renders as a number instead: ``` response_total{direction="outbound", [...] ,classification="failure",grpc_status="2",error=""} 1 ``` Signed-off-by: Alex Leong --- linkerd/app/core/src/metrics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linkerd/app/core/src/metrics.rs b/linkerd/app/core/src/metrics.rs index 831a6a7361..4c7db5a8ee 100644 --- a/linkerd/app/core/src/metrics.rs +++ b/linkerd/app/core/src/metrics.rs @@ -422,7 +422,7 @@ impl FmtLabels for Class { "classification=\"{}\",grpc_status=\"{}\",error=\"\"", class(res.is_ok()), match res { - Ok(code) | Err(code) => code, + Ok(code) | Err(code) => ::from(*code), } ),