Authored by wangning

update

@@ -66,7 +66,7 @@ public class ApiStatisticsAnalyzer implements Serializable { @@ -66,7 +66,7 @@ public class ApiStatisticsAnalyzer implements Serializable {
66 while (itor.hasNext()) { 66 while (itor.hasNext()) {
67 SpanInfo span = (SpanInfo) itor.next(); 67 SpanInfo span = (SpanInfo) itor.next();
68 SpanResult spanResult = new SpanResult(span.getName(), span.getEnd() - span.getBegin(), span.getLevel(), 68 SpanResult spanResult = new SpanResult(span.getName(), span.getEnd() - span.getBegin(), span.getLevel(),
69 - span.getSpanid(), span.getParent(), span.getSrcService(), span.getDstService(), null, null,span.isErrorStatus(),span.getSpanType()); 69 + span.getSpanid(), span.getParent(), span.getSrcService(), span.getDstService(), null, null,span.getErrorCount(),span.getSpanType());
70 spanResultList.add(spanResult); 70 spanResultList.add(spanResult);
71 } 71 }
72 72
@@ -106,8 +106,13 @@ public class ApiStatisticsAnalyzer implements Serializable { @@ -106,8 +106,13 @@ public class ApiStatisticsAnalyzer implements Serializable {
106 106
107 int size = v1.getSpans().size() ; 107 int size = v1.getSpans().size() ;
108 for(int i=0; i<size; i++){ 108 for(int i=0; i<size; i++){
  109 + //计算span平均耗时
109 long d = (v1.getSpans().get(i).getDuration() * v1.getCallTimes() + v2.getSpans().get(i).getDuration() * v2.getCallTimes() ) / result.getCallTimes() ; 110 long d = (v1.getSpans().get(i).getDuration() * v1.getCallTimes() + v2.getSpans().get(i).getDuration() * v2.getCallTimes() ) / result.getCallTimes() ;
110 v1.getSpans().get(i).setDuration(d); 111 v1.getSpans().get(i).setDuration(d);
  112 +
  113 + //计算span异常次数
  114 + int errorCount = v1.getSpans().get(i).getErrorCount() + v2.getSpans().get(i).getErrorCount();
  115 + v1.getSpans().get(i).setErrorCount(errorCount);
111 } 116 }
112 117
113 result.setSpans(v1.getSpans()); 118 result.setSpans(v1.getSpans());
@@ -188,7 +193,7 @@ public class ApiStatisticsAnalyzer implements Serializable { @@ -188,7 +193,7 @@ public class ApiStatisticsAnalyzer implements Serializable {
188 while(it.hasNext()) { 193 while(it.hasNext()) {
189 SpanInfo si = (SpanInfo)it.next(); 194 SpanInfo si = (SpanInfo)it.next();
190 key.append(si.getName()+"|"); 195 key.append(si.getName()+"|");
191 - if(si.isErrorStatus()){ 196 + if(si.getErrorCount()>0){
192 traceErrorStatus = true; 197 traceErrorStatus = true;
193 } 198 }
194 if(si.getSpanType()== SpanType.RESTTEMPLATE){ 199 if(si.getSpanType()== SpanType.RESTTEMPLATE){
@@ -33,8 +33,8 @@ public class SpanInfo implements Serializable { @@ -33,8 +33,8 @@ public class SpanInfo implements Serializable {
33 private String pageId; 33 private String pageId;
34 34
35 private String httpHost; 35 private String httpHost;
36 -  
37 - private boolean errorStatus; 36 + //该span出现异常次数
  37 + private int errorCount;
38 long duration; 38 long duration;
39 39
40 private SpanType spanType; 40 private SpanType spanType;
@@ -23,11 +23,11 @@ public class SpanResult implements Serializable { @@ -23,11 +23,11 @@ public class SpanResult implements Serializable {
23 23
24 List<String> srcIp ; 24 List<String> srcIp ;
25 List<String> dstIp ; 25 List<String> dstIp ;
26 - boolean errorStatus; 26 + int errorCount;
27 SpanType spanType; 27 SpanType spanType;
28 28
29 29
30 - 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 ){ 30 + 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 ){
31 this.spanName = spanName ; 31 this.spanName = spanName ;
32 this.spanId = spanId ; 32 this.spanId = spanId ;
33 this.duration = duration ; 33 this.duration = duration ;
@@ -38,7 +38,7 @@ public class SpanResult implements Serializable { @@ -38,7 +38,7 @@ public class SpanResult implements Serializable {
38 this.dstService = dstService ; 38 this.dstService = dstService ;
39 this.srcIp = srcIp ; 39 this.srcIp = srcIp ;
40 this.dstIp = dstIp ; 40 this.dstIp = dstIp ;
41 - this.errorStatus = errorStatus; 41 + this.errorCount = errorCount;
42 this.spanType=spanType; 42 this.spanType=spanType;
43 } 43 }
44 44
@@ -116,7 +116,7 @@ public class ApiAnalyzeHandler implements IAnalyzeHandler, Serializable { @@ -116,7 +116,7 @@ public class ApiAnalyzeHandler implements IAnalyzeHandler, Serializable {
116 List<SpanResult> list = new ArrayList(); 116 List<SpanResult> list = new ArrayList();
117 for (int i = 0; i < spanList.size(); i++) { 117 for (int i = 0; i < spanList.size(); i++) {
118 list.add(new SpanResult(spanList.get(i).getName(), durationPerStep.get(String.valueOf(spanList.get(i).getName())), 118 list.add(new SpanResult(spanList.get(i).getName(), durationPerStep.get(String.valueOf(spanList.get(i).getName())),
119 - 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())); 119 + 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()));
120 } 120 }
121 121
122 122
@@ -96,7 +96,7 @@ public class TraceAnalyzeHandler implements TraceHandler, Serializable { @@ -96,7 +96,7 @@ public class TraceAnalyzeHandler implements TraceHandler, Serializable {
96 spanInfo.setHttpHost(span.tags().get("http.host")); 96 spanInfo.setHttpHost(span.tags().get("http.host"));
97 //标记span是否是是异常span 97 //标记span是否是是异常span
98 if(StringUtils.isNotBlank(span.tags().get("error"))){ 98 if(StringUtils.isNotBlank(span.tags().get("error"))){
99 - spanInfo.setErrorStatus(true); 99 + spanInfo.setErrorCount(1);
100 } 100 }
101 101
102 String lc = span.tags().get("lc"); 102 String lc = span.tags().get("lc");