Construct apiInvocationUrl using the context of corresponding Api
Fixes wso2/micro-integrator#2430
@@ -133,12 +133,19 @@ public class MetricHandler extends AbstractExtendedSynapseHandler {
if ((serviceInvokePort != internalHttpApiPort) && (null !=
axis2MessageContext.getProperty(MetricConstants.SERVICE_PREFIX))) {
- String context = axis2MessageContext.getProperty(MetricConstants.TRANSPORT_IN_URL).
+ String url = axis2MessageContext.getProperty(MetricConstants.TRANSPORT_IN_URL).
toString();
+ String apiName = getApiName(url, synCtx);
+ if (apiName != null) {
+ String context = "";
+ if (synCtx.getConfiguration() != null) {
+ API api = synCtx.getConfiguration().getAPI(apiName);
+ if (api != null) {
+ context = api.getContext();
+ }
+ }
String apiInvocationUrl = axis2MessageContext.getProperty(MetricConstants.SERVICE_PREFIX).
toString() + context.replaceFirst(DELIMITER, EMPTY);
- String apiName = getApiName(context, synCtx);
- if (apiName != null) {
incrementAPICount(apiName, apiInvocationUrl);
startTimers(synCtx, apiName, SynapseConstants.FAIL_SAFE_MODE_API, apiInvocationUrl);
}
