From 084650d3b23052a6c904f91baa084b62e19d84d2 Mon Sep 17 00:00:00 2001 From: bhashinee Date: Wed, 9 Oct 2024 09:31:53 +0530 Subject: [PATCH] Fix getting 404 response when observability is enabled --- .../observability/metric/handler/MetricHandler.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/components/mediation/data-publishers/org.wso2.micro.integrator.observability/src/main/java/org/wso2/micro/integrator/observability/metric/handler/MetricHandler.java b/components/mediation/data-publishers/org.wso2.micro.integrator.observability/src/main/java/org/wso2/micro/integrator/observability/metric/handler/MetricHandler.java index 9c3ae218df..540d80081f 100644 --- a/components/mediation/data-publishers/org.wso2.micro.integrator.observability/src/main/java/org/wso2/micro/integrator/observability/metric/handler/MetricHandler.java +++ b/components/mediation/data-publishers/org.wso2.micro.integrator.observability/src/main/java/org/wso2/micro/integrator/observability/metric/handler/MetricHandler.java @@ -318,11 +318,10 @@ private String getApiName(String contextPath, MessageContext synCtx) { if (RESTUtils.matchApiPath(contextPath, apiContextPath)) { apiName = api.getName(); synCtx.setProperty(RESTConstants.PROCESSED_API, api); - // if we match to a versioned API, search should stop. - // else check other API's to see if there is a match - if (StringUtils.isNotEmpty(api.getVersion())) { - break; - } + // Since the APIs are already sorted in descending order, we should stop at the first match with the context path. + // Continuing the loop could result in matching a path that only shares the same starting string. + // Ex: /test/ API context path will match with /test/1.0.0 + break; } } return apiName;