From 3c7d4e78910f0f58cd29714210a476ff42c34833 Mon Sep 17 00:00:00 2001 From: wusheng Date: Tue, 12 Apr 2016 17:26:56 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=96=B0=E7=9A=84trace?= =?UTF-8?q?id=20=E6=9F=A5=E8=AF=A2url=EF=BC=8C=E9=81=BF=E5=85=8D=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20#45?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cloud/skywalking/web/controller/SearchController.java | 7 +++++-- .../main/webapp/bower_components/skywalking/js/tracelog.js | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/controller/SearchController.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/controller/SearchController.java index 84adbbcc9..5619ef7df 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/controller/SearchController.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/controller/SearchController.java @@ -10,6 +10,7 @@ import com.ai.cloud.skywalking.web.util.StringUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -17,9 +18,11 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; + import java.util.ArrayList; import java.util.List; @@ -47,9 +50,9 @@ public class SearchController extends BaseController { return ""; } - @RequestMapping(value = "/search/traceId/{traceId:.+}", produces = "application/json; charset=UTF-8") + @RequestMapping(value = "/search/traceId", produces = "application/json; charset=UTF-8") @ResponseBody - public String loadTraceTree(@PathVariable("traceId") String traceId) { + public String loadTraceTree(@RequestParam("traceId") String traceId) { JSONObject jsonObject = new JSONObject(); try { if (StringUtil.isBlank(traceId)) { diff --git a/skywalking-webui/src/main/webapp/bower_components/skywalking/js/tracelog.js b/skywalking-webui/src/main/webapp/bower_components/skywalking/js/tracelog.js index 914d1852d..eca33ae50 100644 --- a/skywalking-webui/src/main/webapp/bower_components/skywalking/js/tracelog.js +++ b/skywalking-webui/src/main/webapp/bower_components/skywalking/js/tracelog.js @@ -88,11 +88,12 @@ function changeData(data) { } function loadTraceTreeData(baseUrl) { - var url = baseUrl + "/search/traceId/" + $("#searchKey").val(); + var url = baseUrl + "/search/traceId"; $.ajax({ type: 'POST', url: url, dataType: 'json', + data: {traceId:$("#searchKey").val()}, async: true, success: function (data) { if (data.code == '200') { From cae97c19231c3c256e8ae4f635c03e22051b4bd2 Mon Sep 17 00:00:00 2001 From: wusheng Date: Tue, 12 Apr 2016 17:35:16 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E6=A0=A1=E5=87=86=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=90=8D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skywalking-sdk-plugin/httpclient-4.3.x-plugin/pom.xml | 4 ++-- skywalking-sdk-plugin/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/skywalking-sdk-plugin/httpclient-4.3.x-plugin/pom.xml b/skywalking-sdk-plugin/httpclient-4.3.x-plugin/pom.xml index a7bab323f..2c74cfc40 100644 --- a/skywalking-sdk-plugin/httpclient-4.3.x-plugin/pom.xml +++ b/skywalking-sdk-plugin/httpclient-4.3.x-plugin/pom.xml @@ -7,10 +7,10 @@ 4.0.0 - skywalking-httpclient-4.3.x-plugin + skywalking-httpClient-4.3.x-plugin jar - httpclient-4.3.x-plugin + httpClient-4.3.x-plugin http://maven.apache.org diff --git a/skywalking-sdk-plugin/pom.xml b/skywalking-sdk-plugin/pom.xml index 3e7a1aabd..ecec8d33a 100644 --- a/skywalking-sdk-plugin/pom.xml +++ b/skywalking-sdk-plugin/pom.xml @@ -12,8 +12,8 @@ mysql-plugin jdbc-plugin web-plugin - httpclient-4.2.x-plugin - httpclient-4.3.x-plugin + httpClient-4.2.x-plugin + httpClient-4.3.x-plugin httpClient-4.x-plugin httpClient-4.x-plugin-dubbox-rest-attachment jedis-2.x-plugin From e49909095fb24cd4c15b092062f27a3c1a491719 Mon Sep 17 00:00:00 2001 From: wusheng Date: Tue, 12 Apr 2016 17:43:19 +0800 Subject: [PATCH 03/13] no message --- pom.xml | 1 + skywalking-sdk-plugin/httpclient-4.2.x-plugin/pom.xml | 4 ++-- skywalking-sdk-plugin/httpclient-4.3.x-plugin/pom.xml | 4 ++-- skywalking-sdk-plugin/pom.xml | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 220406eda..b5756b6db 100644 --- a/pom.xml +++ b/pom.xml @@ -55,4 +55,5 @@ + \ No newline at end of file diff --git a/skywalking-sdk-plugin/httpclient-4.2.x-plugin/pom.xml b/skywalking-sdk-plugin/httpclient-4.2.x-plugin/pom.xml index aec102bfe..9b2e0c501 100644 --- a/skywalking-sdk-plugin/httpclient-4.2.x-plugin/pom.xml +++ b/skywalking-sdk-plugin/httpclient-4.2.x-plugin/pom.xml @@ -7,10 +7,10 @@ 4.0.0 - skywalking-httpClient-4.2.x-plugin + skywalking-httpclient-4.2.x-plugin jar - httpClient-4.2.x-plugin + httpclient-4.2.x-plugin http://maven.apache.org diff --git a/skywalking-sdk-plugin/httpclient-4.3.x-plugin/pom.xml b/skywalking-sdk-plugin/httpclient-4.3.x-plugin/pom.xml index 2c74cfc40..a7bab323f 100644 --- a/skywalking-sdk-plugin/httpclient-4.3.x-plugin/pom.xml +++ b/skywalking-sdk-plugin/httpclient-4.3.x-plugin/pom.xml @@ -7,10 +7,10 @@ 4.0.0 - skywalking-httpClient-4.3.x-plugin + skywalking-httpclient-4.3.x-plugin jar - httpClient-4.3.x-plugin + httpclient-4.3.x-plugin http://maven.apache.org diff --git a/skywalking-sdk-plugin/pom.xml b/skywalking-sdk-plugin/pom.xml index ecec8d33a..3e7a1aabd 100644 --- a/skywalking-sdk-plugin/pom.xml +++ b/skywalking-sdk-plugin/pom.xml @@ -12,8 +12,8 @@ mysql-plugin jdbc-plugin web-plugin - httpClient-4.2.x-plugin - httpClient-4.3.x-plugin + httpclient-4.2.x-plugin + httpclient-4.3.x-plugin httpClient-4.x-plugin httpClient-4.x-plugin-dubbox-rest-attachment jedis-2.x-plugin From 304b3fc51e4400f59392c322476e2c4e5d18ce9c Mon Sep 17 00:00:00 2001 From: ascrutae Date: Wed, 13 Apr 2016 12:46:25 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E9=93=BE=E8=BF=87=E9=95=BF=EF=BC=8C=E5=AF=BC=E8=87=B4=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=B4=A9=E6=BA=83=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../skywalking/web/bo/TraceTreeInfo.java | 9 +++ .../skywalking/web/dao/impl/TraceNodeDao.java | 64 +++++++++++++++---- .../web/dao/inter/ITraceNodeDao.java | 3 +- .../web/service/impl/TraceTreeService.java | 9 +-- .../skywalking/js/tracelog.js | 2 +- .../main/webapp/pages/common/traceInfo.ftl | 2 +- 6 files changed, 66 insertions(+), 23 deletions(-) diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/bo/TraceTreeInfo.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/bo/TraceTreeInfo.java index 18820a3f1..5ea9fdfd6 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/bo/TraceTreeInfo.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/bo/TraceTreeInfo.java @@ -7,6 +7,7 @@ public class TraceTreeInfo { private long beginTime; private long endTime; private List nodes; + private int nodeSize; public TraceTreeInfo(String traceId, List nodes) { this.traceId = traceId; @@ -44,4 +45,12 @@ public class TraceTreeInfo { public void setNodes(List nodes) { this.nodes = nodes; } + + public void setNodeSize(int nodeSize) { + this.nodeSize = nodeSize; + } + + public int getNodeSize() { + return nodeSize; + } } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/impl/TraceNodeDao.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/impl/TraceNodeDao.java index f5812694b..5cb7d3a00 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/impl/TraceNodeDao.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/impl/TraceNodeDao.java @@ -1,6 +1,7 @@ package com.ai.cloud.skywalking.web.dao.impl; import com.ai.cloud.skywalking.web.bo.TraceNodeInfo; +import com.ai.cloud.skywalking.web.bo.TraceTreeInfo; import com.ai.cloud.skywalking.web.dao.inter.ITraceNodeDao; import com.ai.cloud.skywalking.web.util.Constants; import com.ai.cloud.skywalking.web.util.HBaseUtils; @@ -10,14 +11,18 @@ import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.Result; +import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Table; +import org.apache.hadoop.hbase.filter.ColumnCountGetFilter; import org.apache.hadoop.hbase.util.Bytes; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -33,28 +38,59 @@ public class TraceNodeDao implements ITraceNodeDao { @Override - public Map queryTraceNodesByTraceId(String traceId) throws IOException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { + public TraceTreeInfo queryTraceNodesByTraceId(String traceId) throws IOException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { + TraceTreeInfo traceTreeInfo = null; + Table table = hBaseUtils.getConnection().getTable(TableName.valueOf(CALL_CHAIN_TABLE_NAME)); Get g = new Get(Bytes.toBytes(traceId)); + g.setFilter(new ColumnCountGetFilter(10001)); Result r = table.get(g); Map traceLogMap = new HashMap(); Map rpcMap = new HashMap(); - for (Cell cell : r.rawCells()) { - if (cell.getValueArray().length > 0) { - String colId = Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(), - cell.getQualifierLength()); - TraceNodeInfo tmpEntry = TraceNodeInfo.convert( - Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()), colId); - // 特殊处理RPC的服务端信息 - if (colId.endsWith(Constants.RPC_END_FLAG)) { - rpcMap.put(colId.substring(0, colId.lastIndexOf(Constants.RPC_END_FLAG)), tmpEntry); - } else { - SortUtil.addCurNodeTreeMapKey(traceLogMap, colId, tmpEntry); + int totalSize = 10001; + if (r.rawCells().length < 10000) { + for (Cell cell : r.rawCells()) { + if (cell.getValueArray().length > 0) { + dealSingleSpanCell(traceLogMap, rpcMap, cell); } } + totalSize = r.rawCells().length; + } else { + g = new Get(Bytes.toBytes(traceId)); + g.addColumn("call-chain".getBytes(), "0".getBytes()); + g.addColumn("call-chain".getBytes(), "0.0".getBytes()); + r = table.get(g); + //获取0和0.0两个节点 + Cell cell = r.getColumnLatestCell("call-chain".getBytes(), "0".getBytes()); + dealSingleSpanCell(traceLogMap, rpcMap, cell); + cell = r.getColumnLatestCell("call-chain".getBytes(), "0.0".getBytes()); + dealSingleSpanCell(traceLogMap, rpcMap, cell); } computeRPCInfo(rpcMap, traceLogMap); - return traceLogMap; + + if (traceLogMap != null && traceLogMap.size() > 0) { + List nodes = new ArrayList(); + nodes.addAll(traceLogMap.values()); + traceTreeInfo = new TraceTreeInfo(traceId, nodes); + traceTreeInfo.setNodeSize(totalSize); + } + + return traceTreeInfo; + } + + private void dealSingleSpanCell(Map traceLogMap, Map rpcMap, Cell cell) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + if (cell.getValueArray().length == 0) + return; + String colId = Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(), + cell.getQualifierLength()); + TraceNodeInfo tmpEntry = TraceNodeInfo.convert( + Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()), colId); + // 特殊处理RPC的服务端信息 + if (colId.endsWith(Constants.RPC_END_FLAG)) { + rpcMap.put(colId.substring(0, colId.lastIndexOf(Constants.RPC_END_FLAG)), tmpEntry); + } else { + SortUtil.addCurNodeTreeMapKey(traceLogMap, colId, tmpEntry); + } } private void computeRPCInfo(Map rpcMap, Map traceLogMap) { @@ -76,7 +112,7 @@ public class TraceNodeDao implements ITraceNodeDao { clientLog.setAddress(serverLog.getAddress()); if (StringUtil.isBlank(clientLog.getExceptionStack())) { clientLog.setExceptionStack(serverLog.getExceptionStack()); - }else{ + } else { clientLog.setServerExceptionStr(serverLog.getServerExceptionStr()); } System.out.println("1"); diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/inter/ITraceNodeDao.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/inter/ITraceNodeDao.java index 686e6c638..9a7f47896 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/inter/ITraceNodeDao.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/dao/inter/ITraceNodeDao.java @@ -1,6 +1,7 @@ package com.ai.cloud.skywalking.web.dao.inter; import com.ai.cloud.skywalking.web.bo.TraceNodeInfo; +import com.ai.cloud.skywalking.web.bo.TraceTreeInfo; import java.io.IOException; import java.lang.reflect.InvocationTargetException; @@ -11,5 +12,5 @@ import java.util.Map; */ public interface ITraceNodeDao { - Map queryTraceNodesByTraceId(String traceId) throws IOException, IllegalAccessException, NoSuchMethodException, InvocationTargetException; + TraceTreeInfo queryTraceNodesByTraceId(String traceId) throws IOException, IllegalAccessException, NoSuchMethodException, InvocationTargetException; } diff --git a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/impl/TraceTreeService.java b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/impl/TraceTreeService.java index c8d112a18..cd70f04a3 100644 --- a/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/impl/TraceTreeService.java +++ b/skywalking-webui/src/main/java/com/ai/cloud/skywalking/web/service/impl/TraceTreeService.java @@ -22,12 +22,10 @@ public class TraceTreeService implements ITraceTreeService { @Override public TraceTreeInfo queryTraceTreeByTraceId(String traceId) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException, IOException { - TraceTreeInfo traceTreeInfo = null; - Map traceLogMap = traceTreeDao.queryTraceNodesByTraceId(traceId); - if (traceLogMap != null && traceLogMap.size() > 0) { - List nodes = new ArrayList(); - nodes.addAll(traceLogMap.values()); + TraceTreeInfo traceTreeInfo = traceTreeDao.queryTraceNodesByTraceId(traceId); + if (traceTreeInfo != null) { + List nodes = traceTreeInfo.getNodes(); final List endTime = new ArrayList(); endTime.add(0, nodes.get(0).getEndDate()); Collections.sort(nodes, new Comparator() { @@ -43,7 +41,6 @@ public class TraceTreeService implements ITraceTreeService { } }); long beginTime = nodes.get(0).getStartDate(); - traceTreeInfo = new TraceTreeInfo(traceId, nodes); traceTreeInfo.setBeginTime(beginTime); traceTreeInfo.setEndTime(endTime.get(0)); } diff --git a/skywalking-webui/src/main/webapp/bower_components/skywalking/js/tracelog.js b/skywalking-webui/src/main/webapp/bower_components/skywalking/js/tracelog.js index eca33ae50..7599d48d4 100644 --- a/skywalking-webui/src/main/webapp/bower_components/skywalking/js/tracelog.js +++ b/skywalking-webui/src/main/webapp/bower_components/skywalking/js/tracelog.js @@ -14,7 +14,7 @@ function changeData(data) { var totalTime = result.traceTree.totalTime; result.traceTree.startTime = data.beginTime; result.traceTree.endTime = data.endTime; - result.traceTree.totalSize = data.nodes.length; + result.traceTree.totalSize = data.nodeSize; result.traceTree.startTimeStr = convertDate(new Date(result.traceTree.startTime)); result.traceTree.callIP = data.nodes[0].address; var tmpNode; diff --git a/skywalking-webui/src/main/webapp/pages/common/traceInfo.ftl b/skywalking-webui/src/main/webapp/pages/common/traceInfo.ftl index a0a17572d..55a7c0031 100644 --- a/skywalking-webui/src/main/webapp/pages/common/traceInfo.ftl +++ b/skywalking-webui/src/main/webapp/pages/common/traceInfo.ftl @@ -125,7 +125,7 @@
{{>traceId}}
- 调度入口IP:{{>callIP}},开始时间:{{>startTimeStr}},{{>totalSize}}条调用记录,消耗总时长:{{>totalTime}}ms。 + 调度入口IP:{{>callIP}},开始时间:{{>startTimeStr}},{{if totalSize > 10000}}调用记录大于10000条,无法展示全部,{{else}}{{>totalSize}}条调用记录,{{/if}}消耗总时长:{{>totalTime}}ms。