Skip to content

Commit

Permalink
Merge pull request #146 from zwq0317/master
Browse files Browse the repository at this point in the history
fix part of the url monitoring data in springMVC is not available
  • Loading branch information
zxy0728 authored Jan 5, 2018
2 parents 8a84f45 + 99fff7f commit 5169fad
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ private void getSpringMVCURLs(String springMVCBaseUrl, Map<String, Set<String>>

// check if there is suffix, such as *.do
if (allIndex != realSpringMVCBaseUrl.length() - 1) {
suffix = realSpringMVCBaseUrl.substring(allIndex + 1);
suffix = realSpringMVCBaseUrl.substring(allIndex + 1, realSpringMVCBaseUrl.length() - 1);
}

// get the real access path
Expand Down Expand Up @@ -946,7 +946,9 @@ private void getSpringMVCURLs(String springMVCBaseUrl, Map<String, Set<String>>
methodServiceURL = formatRelativePath(serviceURL + "/" + methodRelativePath);
}
else {
methodServiceURL = formatRelativePath(serviceURL + "/" + methodRelativePath + suffix);
// endwith "#" means the suffix is added from springMVCBaseUrl,should be removed while on query
methodServiceURL = formatRelativePath(
serviceURL + "/" + methodRelativePath + suffix + "#");
}

compServicesURLs.add(methodServiceURL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4192,7 +4192,7 @@ var mvcObj={
* App Service URL 性能显示
*/
sb.append("<div class='indexItem'>");
sb.append("<div class='indexItemHead'><span class='indexItemTag'>"+(i+1)+"</span><span class='indexItemId'>"+url+"</span></div>");
sb.append("<div class='indexItemHead'><span class='indexItemTag'>"+(i+1)+"</span><span class='indexItemId'>"+url.replace("#","")+"</span></div>");
sb.append("<div class='indexItemContent'>");
sb.append("QPM<span class='osRate' id='"+url+"_appservicechart_QPS'>-</span>&nbsp;&nbsp;" +
"全程平均响应(ms)<span class='osRate' id='"+url+"_appservicechart_RT'>-</span>&nbsp;&nbsp;" +
Expand Down Expand Up @@ -4240,6 +4240,21 @@ var mvcObj={
*/
monitorCfg.url.ip=sObj.ip;
monitorCfg.url.svrid=sObj.svrid;

//url以"#"结尾意味着需要去除后缀,
for(var i=0;i<sObj.urls.length;i++){

if(!sObj.urls[i].endsWith("#")){
continue;
}

var lastSeparatorIndex = sObj.urls[i].lastIndexOf("/");
var suffixIndex = sObj.urls[i].lastIndexOf(".");
//最后一个分隔符'/'之后的点认为是后缀
if(suffixIndex > lastSeparatorIndex){
sObj.urls[i] = sObj.urls[i].substring(0,suffixIndex);
}
}
monitorCfg.url.urls=sObj.urls;
/**
* Step 2: refresh service url
Expand All @@ -4265,6 +4280,21 @@ var mvcObj={

var urlMO=urlMOs[key];

//正常情况下返回结果的key应该在appURLQPSCfg.seriesMap,若不在说明做了后缀的截取,需要恢复
if(!(key in appURLQPSCfg.seriesMap)){
for(var seriesMapKey in appURLQPSCfg.seriesMap){
//按照去除后缀的逻辑把seriesMapKey里的后缀去掉,若与当前key相同说明是同一个url
var lastSeparatorIndex = seriesMapKey.lastIndexOf("/");
var suffixIndex = seriesMapKey.lastIndexOf(".");
if(suffixIndex > lastSeparatorIndex && key == seriesMapKey.substring(0,suffixIndex)){
//将key替换成含有后缀的形式,保证数据可以正确设置
key = seriesMapKey;
//将urlMO["id"]替换成含有后缀形式,保证数据可以正常显示
urlMO["id"]=key;
break;
}
}
}
var tps = urlMO["tps"];
var tavg = urlMO["tavg"];
var err = urlMO["err"];
Expand Down Expand Up @@ -4718,7 +4748,7 @@ var mvcObj={

for(var i=0;i<cptservice.length;i++) {

sb.append("<div class='kvSubField'>"+cptservice[i]+"</div>");
sb.append("<div class='kvSubField'>"+cptservice[i].replace("#","")+"</div>");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,18 @@ public boolean match(String targetUrl) {
}

/**
* Step 3: if the targetUrl possible has path param, need check if the path param count match
* Step 3: if there is a suffix such as xxx.do,remove the suffix and try to match again
*/
int suffixIndex = targetUrl.lastIndexOf(".");
if (suffixIndex > -1) {
String targetUrlWithoutSuffix = targetUrl.substring(0, suffixIndex);
if (targetUrlWithoutSuffix.endsWith(this.pathPattern) == true) {
return true;
}
}

/**
* Step 4: if the targetUrl possible has path param, need check if the path param count match
*/
String pathParamStr = targetUrl.substring(index + this.pathPattern.length());

Expand All @@ -111,7 +122,7 @@ public boolean match(String targetUrl) {
}

/**
* Step 4: check if allow abMatch,if yes, as part, then return true, mostly for servlet or filter
* Step 5: check if allow abMatch,if yes, as part, then return true, mostly for servlet or filter
*/
if (this.allowAbMatch == true) {
return true;
Expand Down

0 comments on commit 5169fad

Please sign in to comment.