...
|
...
|
@@ -55,23 +55,19 @@ public class PageAnalyzeHandler implements TraceHandler, Serializable { |
|
|
Span span = ite.next();
|
|
|
//只取包含pageID的span
|
|
|
pageId = span.tags().get(FROM_PAGE);
|
|
|
|
|
|
if (!StringUtils.isEmpty(pageId) && !StringUtils.isEmpty(span.getName())) {
|
|
|
//不区分安卓和IOS
|
|
|
if (pageId.startsWith("iFP") || pageId.startsWith("aFP")) {
|
|
|
pageId = pageId.substring(1);
|
|
|
}
|
|
|
spanInfo = new SpanInfo();
|
|
|
spanInfo.setPageId(pageId);
|
|
|
spanInfo.setName(span.getName());
|
|
|
spanInfo.setBegin(span.getBegin());
|
|
|
spanInfo.setEnd(span.getEnd());
|
|
|
spanInfo.setTraceid(Span.idToHex(span.getTraceId()));
|
|
|
spanInfo.setSpanid(Span.idToHex(span.getSpanId()));
|
|
|
spanInfo.setService(spans.getHost().getServiceName());
|
|
|
spanInfo.setIp(spans.getHost().getAddress());
|
|
|
result.add(spanInfo);
|
|
|
if (StringUtils.isEmpty(pageId) || StringUtils.isEmpty(span.getName()) || span.getName().equals("http:/")) {
|
|
|
continue;
|
|
|
}
|
|
|
//不区分安卓和IOS
|
|
|
if (pageId.startsWith("iFP") || pageId.startsWith("aFP")) {
|
|
|
pageId = pageId.substring(1);
|
|
|
}
|
|
|
spanInfo = new SpanInfo();
|
|
|
spanInfo.setPageId(pageId);
|
|
|
spanInfo.setName(span.getName().replace("http:/",""));
|
|
|
spanInfo.setBegin(span.getBegin());
|
|
|
spanInfo.setEnd(span.getEnd());
|
|
|
result.add(spanInfo);
|
|
|
}
|
|
|
return result.iterator();
|
|
|
}
|
...
|
...
|
@@ -89,7 +85,7 @@ public class PageAnalyzeHandler implements TraceHandler, Serializable { |
|
|
ApiTraceResult result = new ApiTraceResult();
|
|
|
result.setDuration(spanInfo.getEnd() - spanInfo.getBegin());
|
|
|
result.setCallTimes(1);
|
|
|
list.add(new Tuple2<>(spanInfo.getPageId() + SPLIT_STR + spanInfo.getName().replace("http:/", ""), result));
|
|
|
list.add(new Tuple2<>(spanInfo.getPageId() + SPLIT_STR + spanInfo.getName(), result));
|
|
|
}
|
|
|
|
|
|
return list.iterator();
|
...
|
...
|
@@ -128,19 +124,20 @@ public class PageAnalyzeHandler implements TraceHandler, Serializable { |
|
|
String api = tuple2._1.split(SPLIT_STR)[1];
|
|
|
|
|
|
String rowKey1 = pageId + "-" + now + "-" + api;
|
|
|
logger.info("rowKey is {}", rowKey1);
|
|
|
Put put1 = new Put(Bytes.toBytes(rowKey1));
|
|
|
put1.addColumn(Bytes.toBytes("data"), Bytes.toBytes("times"), Bytes.toBytes(tuple2._2.getCallTimes()));
|
|
|
put1.addColumn(Bytes.toBytes("data"), Bytes.toBytes("duration"), Bytes.toBytes(tuple2._2.getDuration() / tuple2._2.getCallTimes()));
|
|
|
put1.addColumn(Bytes.toBytes("data"), Bytes.toBytes("total_duration"), Bytes.toBytes(tuple2._2.getDuration()));
|
|
|
puts1.add(put1);
|
|
|
logger.info("put data to trace_page_analyze_minutes, {}", put1);
|
|
|
//logger.info("put data to trace_page_analyze_minutes, {}", put1);
|
|
|
|
|
|
|
|
|
String rowKey2 = api + "-" + now + "-" + pageId;
|
|
|
Put put2 = new Put(Bytes.toBytes(rowKey2));
|
|
|
put2.addColumn(Bytes.toBytes("data"), Bytes.toBytes("times"), Bytes.toBytes(tuple2._2.getCallTimes()));
|
|
|
puts2.add(put2);
|
|
|
logger.info("put data to trace_api_source_analyze_minutes, {}", put2);
|
|
|
//logger.info("put data to trace_api_source_analyze_minutes, {}", put2);
|
|
|
|
|
|
}
|
|
|
resultTable1.put(puts1);
|
...
|
...
|
|