From 2c64bc93ee09bf0fabfaa4bb6011811a2d3e138a Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Fri, 28 Jun 2024 11:50:52 +0530 Subject: [PATCH] Include response error count metric --- .../observability/metrics/BallerinaMetricsObserver.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/observability/metrics/BallerinaMetricsObserver.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/observability/metrics/BallerinaMetricsObserver.java index 8b13a742095e..d796ed991094 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/observability/metrics/BallerinaMetricsObserver.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/observability/metrics/BallerinaMetricsObserver.java @@ -127,6 +127,10 @@ private void stopObservation(ObserverContext observerContext) { "Total response response time for all requests", tags)).increment(duration); metricRegistry.counter(new MetricId("requests_total", "Total number of requests", tags)).increment(); + if (statusCode != null && 400 <= statusCode && statusCode < 600) { + metricRegistry.counter(new MetricId("response_errors_total", + "Total number of response errors", tags)).increment(); + } } catch (RuntimeException e) { handleError("multiple metrics", tags, e); }