Authored by wangning

ip判断修改

... ... @@ -3,6 +3,7 @@ package com.yoho.trace.anaylzer.model;
import lombok.Data;
import java.io.Serializable;
import java.util.Map;
/**
* Created by xjipeng on 2017/10/12.
... ... @@ -30,4 +31,6 @@ public class SpanInfo implements Serializable {
* 来源页面ID
*/
private String pageId;
private Map<String, String> tags;
}
\ No newline at end of file
... ...
... ... @@ -88,6 +88,7 @@ public class TraceAnalyzeHandler implements TraceHandler, Serializable {
spanInfo.setEndpoint(logEvent);
spanInfo.setIp(spans.getHost().getAddress());
spanInfo.setReceive(spans.getReceive());
spanInfo.setTags(span.tags());
spanInfoList.add(new Tuple2<>(spanInfo.getTraceid(), spanInfo));
}
}
... ... @@ -256,7 +257,7 @@ public class TraceAnalyzeHandler implements TraceHandler, Serializable {
@Override
public void call(JavaPairRDD<String, ApiTraceResult> apiResultRdd) throws Exception {
ApiStatisticsResultStore.store(apiResultRdd, "trace_api_analyze_minutes");
ApiStatisticsResultStore.store(apiResultRdd, "trace_api_analyze_minutes_wn");
}
});
... ... @@ -279,9 +280,25 @@ public class TraceAnalyzeHandler implements TraceHandler, Serializable {
List<SpanInfo> sortSpanList = sortTrace.getSortSpanList();
for (SpanInfo spanInfo : sortSpanList) {
String ip = "";
//只有root和resttemplate才会生成ip
if(spanInfo.getTraceid().equals(spanInfo.getSpanid())){
ip = spanInfo.getIp();
}else{
if(spanInfo.getTags()!=null){
String httpHost = spanInfo.getTags().get("http.host");
if(StringUtils.isNoneBlank(httpHost)){
ip = httpHost;
}
}
}
if(StringUtils.isBlank(ip)){
continue;
}
SpanIpResult spanIpResult = new SpanIpResult();
String spanName = spanInfo.getName();
String ip = spanInfo.getIp();
long duration = spanInfo.getEnd() - spanInfo.getBegin();
spanIpResult.setAvgDuration(duration);
spanIpResult.setIp(ip);
... ...