Authored by wangning

update

... ... @@ -66,7 +66,7 @@ public class ApiStatisticsAnalyzer implements Serializable {
while (itor.hasNext()) {
SpanInfo span = (SpanInfo) itor.next();
SpanResult spanResult = new SpanResult(span.getName(), span.getEnd() - span.getBegin(), span.getLevel(),
span.getSpanid(), span.getParent(), span.getSrcService(), span.getDstService(), null, null,span.isErrorStatus(),span.getSpanType());
span.getSpanid(), span.getParent(), span.getSrcService(), span.getDstService(), null, null,span.getErrorCount(),span.getSpanType());
spanResultList.add(spanResult);
}
... ... @@ -106,8 +106,13 @@ public class ApiStatisticsAnalyzer implements Serializable {
int size = v1.getSpans().size() ;
for(int i=0; i<size; i++){
//计算span平均耗时
long d = (v1.getSpans().get(i).getDuration() * v1.getCallTimes() + v2.getSpans().get(i).getDuration() * v2.getCallTimes() ) / result.getCallTimes() ;
v1.getSpans().get(i).setDuration(d);
//计算span异常次数
int errorCount = v1.getSpans().get(i).getErrorCount() + v2.getSpans().get(i).getErrorCount();
v1.getSpans().get(i).setErrorCount(errorCount);
}
result.setSpans(v1.getSpans());
... ... @@ -188,7 +193,7 @@ public class ApiStatisticsAnalyzer implements Serializable {
while(it.hasNext()) {
SpanInfo si = (SpanInfo)it.next();
key.append(si.getName()+"|");
if(si.isErrorStatus()){
if(si.getErrorCount()>0){
traceErrorStatus = true;
}
if(si.getSpanType()== SpanType.RESTTEMPLATE){
... ...
... ... @@ -33,8 +33,8 @@ public class SpanInfo implements Serializable {
private String pageId;
private String httpHost;
private boolean errorStatus;
//该span出现异常次数
private int errorCount;
long duration;
private SpanType spanType;
... ...
... ... @@ -23,11 +23,11 @@ public class SpanResult implements Serializable {
List<String> srcIp ;
List<String> dstIp ;
boolean errorStatus;
int errorCount;
SpanType spanType;
public SpanResult(String spanName, long duration,int level,String spanId, String parent, String srcService, String dstService, List<String> srcIp, List<String> dstIp,boolean errorStatus,SpanType spanType ){
public SpanResult(String spanName, long duration,int level,String spanId, String parent, String srcService, String dstService, List<String> srcIp, List<String> dstIp,int errorCount,SpanType spanType ){
this.spanName = spanName ;
this.spanId = spanId ;
this.duration = duration ;
... ... @@ -38,7 +38,7 @@ public class SpanResult implements Serializable {
this.dstService = dstService ;
this.srcIp = srcIp ;
this.dstIp = dstIp ;
this.errorStatus = errorStatus;
this.errorCount = errorCount;
this.spanType=spanType;
}
... ...
... ... @@ -116,7 +116,7 @@ public class ApiAnalyzeHandler implements IAnalyzeHandler, Serializable {
List<SpanResult> list = new ArrayList();
for (int i = 0; i < spanList.size(); i++) {
list.add(new SpanResult(spanList.get(i).getName(), durationPerStep.get(String.valueOf(spanList.get(i).getName())),
spanList.get(i).getLevel(), spanList.get(i).getSpanid() ,spanList.get(i).getParent() , spanList.get(i).getSrcService(), spanList.get(i).getDstService(), null, null,spanList.get(i).isErrorStatus(),spanList.get(i).getSpanType()));
spanList.get(i).getLevel(), spanList.get(i).getSpanid() ,spanList.get(i).getParent() , spanList.get(i).getSrcService(), spanList.get(i).getDstService(), null, null,spanList.get(i).getErrorCount(),spanList.get(i).getSpanType()));
}
... ...
... ... @@ -96,7 +96,7 @@ public class TraceAnalyzeHandler implements TraceHandler, Serializable {
spanInfo.setHttpHost(span.tags().get("http.host"));
//标记span是否是是异常span
if(StringUtils.isNotBlank(span.tags().get("error"))){
spanInfo.setErrorStatus(true);
spanInfo.setErrorCount(1);
}
String lc = span.tags().get("lc");
... ...