提交 54ae4b93 编写于 作者: P pengys5

repair bug id split and node finder

上级 dac1a241
......@@ -52,13 +52,19 @@ abstract class AbstractNodeAnalysis extends RecordAnalysisMember {
dataJsonObj.addProperty(NodeIndex.Time_Slice, timeSlice);
logger.debug("span id=%s, kind=%s, layer=%s, component=%s, code=%s", span.getSpanId(), kind, layer, component, code);
String id = timeSlice + Const.ID_SPLIT + code;
logger.debug("leaf client node: %s", dataJsonObj.toString());
dataJsonObj.addProperty(NodeIndex.Code, code);
dataJsonObj.addProperty(NodeIndex.NickName, code);
setRecord(id, dataJsonObj);
if (Tags.SPAN_KIND_CLIENT.equals(kind) && ClientSpanIsLeafTools.isLeaf(span.getSpanId(), spanList)) {
logger.debug("The span id %s which kind is client and is a leaf span", span.getSpanId());
code = SpanPeersTools.getPeers(span);
dataJsonObj.addProperty(NodeIndex.Code, code);
dataJsonObj.addProperty(NodeIndex.NickName, code);
String id = timeSlice + Const.ID_SPLIT + code;
id = timeSlice + Const.ID_SPLIT + code;
logger.debug("leaf client node: %s", dataJsonObj.toString());
setRecord(id, dataJsonObj);
} else if (Tags.SPAN_KIND_SERVER.equals(kind) && span.getParentSpanId() == -1) {
......@@ -75,7 +81,7 @@ abstract class AbstractNodeAnalysis extends RecordAnalysisMember {
logger.debug("user node: %s", userDataJsonObj.toString());
setRecord(userId, userDataJsonObj);
String id = timeSlice + Const.ID_SPLIT + code;
id = timeSlice + Const.ID_SPLIT + code;
dataJsonObj.addProperty(NodeIndex.NickName, code);
logger.debug("refs node: %s", dataJsonObj.toString());
setRecord(id, dataJsonObj);
......@@ -83,7 +89,7 @@ abstract class AbstractNodeAnalysis extends RecordAnalysisMember {
for (TraceSegmentRef segmentRef : segment.getRefs()) {
String nickName = Const.PEERS_FRONT_SPLIT + segmentRef.getPeerHost() + Const.PEERS_BEHIND_SPLIT;
dataJsonObj.addProperty(NodeIndex.NickName, nickName);
String id = timeSlice + Const.ID_SPLIT + code;
id = timeSlice + Const.ID_SPLIT + code;
logger.debug("refs node: %s", dataJsonObj.toString());
setRecord(id, dataJsonObj);
}
......
......@@ -20,7 +20,7 @@ public class MetricData extends AbstractHashMessage {
this.id = id;
value = new HashMap<>();
String[] ids = id.split(Const.ID_SPLIT);
String[] ids = id.split(Const.IDS_SPLIT);
String slice = ids[0];
String aggId = "";
for (int i = 1; i < ids.length; i++) {
......
......@@ -17,7 +17,7 @@ public class RecordData extends AbstractHashMessage {
public RecordData(String key) {
super(key);
this.id = key;
String[] ids = id.split(Const.ID_SPLIT);
String[] ids = id.split(Const.IDS_SPLIT);
for (int i = 1; i < ids.length; i++) {
if (i == 1) {
this.aggId = ids[i];
......
......@@ -2,3 +2,6 @@ cluster.current.hostname=127.0.0.1
cluster.current.port=1000
cluster.current.roles=[WorkersListener]
#cluster.seed_nodes=["akka.tcp://CollectorSystem@127.0.0.1:1000"]
es.cluster.name=
es.cluster.nodes=
......@@ -100,11 +100,13 @@ public class SegmentPostTestCase {
// @Test
public void testPostSample1Segment() throws Exception {
HttpClientTools.INSTANCE.post("http://localhost:7001/segment", sample1);
HttpClientTools.INSTANCE.post("http://localhost:7001/segment", sample2);
HttpClientTools.INSTANCE.post("http://localhost:7001/segment", sample3);
// HttpClientTools.INSTANCE.post("http://localhost:7001/segment", sample1);
// HttpClientTools.INSTANCE.post("http://localhost:7001/segment", sample2);
// HttpClientTools.INSTANCE.post("http://localhost:7001/segment", sample3);
HttpClientTools.INSTANCE.post("http://localhost:7001/segment", test);
}
private String test = "[{\"ts\":\"Segment.1490346133016.1756883859.5046.1.1\",\"st\":1490346133015,\"et\":1490346133041,\"ss\":[{\"si\":0,\"ps\":-1,\"st\":1490346133020,\"et\":1490346133041,\"on\":\"H2/JDBI/Statement/execute\",\"ts\":{\"db.instance\":\"dataSource\",\"span.layer\":\"db\",\"db.type\":\"sql\",\"component\":\"H2\",\"span.kind\":\"client\",\"db.statement\":\"CREATE TABLE CACHE_TABLE ( id INTEGER PRIMARY KEY AUTO_INCREMENT, CACHE_KEY VARCHAR(30), CACHE_VALUE VARCHAR(50) )\",\"peer.host\":\"localhost\"},\"tb\":{},\"ti\":{\"peer.port\":-1},\"lo\":[]}],\"ac\":\"cache-service\",\"gt\":[\"Trace.1490346133019.1756883859.5046.1.2\"],\"sampled\":true,\"minute\":201703241702,\"hour\":201703241700,\"day\":201703240000,\"aggId\":null}]";
private String sample1 = "[{\"ts\":\"Segment.1490166134993.56087145.45017.26.1\",\"st\":1490166134993,\"et\":1490166134996,\"rs\":[{\"ts\":\"Segment.1490166134989.142811427.45029.64.1\",\"si\":2,\"ac\":\"portal-service\",\"ph\":\"127.0.0.1:8002\"}],\"ss\":[{\"si\":2,\"ps\":1,\"st\":1490166134993,\"et\":1490166134993,\"on\":\"Jedis/getClient\",\"ts\":{\"span.layer\":\"db\",\"component\":\"Redis\",\"db.type\":\"Redis\",\"peer.host\":\"127.0.0.1\",\"span.kind\":\"client\"},\"tb\":{},\"ti\":{\"peer.port\":6379},\"lo\":[]},{\"si\":3,\"ps\":1,\"st\":1490166134993,\"et\":1490166134993,\"on\":\"Jedis/getClient\",\"ts\":{\"span.layer\":\"db\",\"component\":\"Redis\",\"db.type\":\"Redis\",\"peer.host\":\"127.0.0.1\",\"span.kind\":\"client\"},\"tb\":{},\"ti\":{\"peer.port\":6379},\"lo\":[]},{\"si\":4,\"ps\":1,\"st\":1490166134993,\"et\":1490166134993,\"on\":\"Jedis/isConnected\",\"ts\":{\"span.layer\":\"db\",\"component\":\"Redis\",\"db.type\":\"Redis\",\"peer.host\":\"127.0.0.1\",\"span.kind\":\"client\"},\"tb\":{},\"ti\":{\"peer.port\":6379},\"lo\":[]},{\"si\":5,\"ps\":1,\"st\":1490166134993,\"et\":1490166134994,\"on\":\"Jedis/ping\",\"ts\":{\"span.layer\":\"db\",\"component\":\"Redis\",\"db.type\":\"Redis\",\"peer.host\":\"127.0.0.1\",\"span.kind\":\"client\"},\"tb\":{},\"ti\":{\"peer.port\":6379},\"lo\":[]},{\"si\":6,\"ps\":1,\"st\":1490166134994,\"et\":1490166134994,\"on\":\"Jedis/get\",\"ts\":{\"span.layer\":\"db\",\"component\":\"Redis\",\"db.type\":\"Redis\",\"peer.host\":\"127.0.0.1\",\"span.kind\":\"client\",\"db.statement\":\"get test\"},\"tb\":{},\"ti\":{\"peer.port\":6379},\"lo\":[]},{\"si\":7,\"ps\":1,\"st\":1490166134996,\"et\":1490166134996,\"on\":\"H2/JDBI/PreparedStatement/executeQuery\",\"ts\":{\"db.instance\":\"dataSource\",\"span.layer\":\"db\",\"db.type\":\"sql\",\"component\":\"H2\",\"span.kind\":\"client\",\"db.statement\":\"SELECT id,CACHE_VALUE, CACHE_KEY FROM CACHE_TABLE WHERE CACHE_KEY \\u003d ?\",\"peer.host\":\"localhost\"},\"tb\":{},\"ti\":{\"peer.port\":-1},\"lo\":[]},{\"si\":8,\"ps\":1,\"st\":1490166134996,\"et\":1490166134996,\"on\":\"H2/JDBI/Connection/close\",\"ts\":{\"db.instance\":\"dataSource\",\"span.layer\":\"db\",\"db.type\":\"sql\",\"component\":\"H2\",\"span.kind\":\"client\",\"db.statement\":\"\",\"peer.host\":\"localhost\"},\"tb\":{},\"ti\":{\"peer.port\":-1},\"lo\":[]},{\"si\":1,\"ps\":0,\"st\":0,\"et\":1490166134996,\"on\":\"Motan_default_rpc_com.a.eye.skywalking.test.cache.CacheService.findCache(java.lang.String)\",\"ts\":{\"requestId\":\"1562552445165371397\"},\"tb\":{},\"ti\":{},\"lo\":[]},{\"si\":0,\"ps\":-1,\"st\":1490166134993,\"et\":1490166134996,\"on\":\"com.a.eye.skywalking.test.cache.CacheService.findCache(java.lang.String)\",\"ts\":{\"span.layer\":\"rpc\",\"component\":\"Motan\",\"span.kind\":\"server\"},\"tb\":{},\"ti\":{},\"lo\":[]}],\"ac\":\"cache-service\",\"gt\":[\"Trace.1490166134989.142811427.45029.64.2\"]},{\"ts\":\"Segment.1490166135023.56087145.45017.27.1\",\"st\":1490166135023,\"et\":1490166135026,\"rs\":[{\"ts\":\"Segment.1490166134989.142811427.45029.64.1\",\"si\":6,\"ac\":\"portal-service\",\"ph\":\"127.0.0.1:8002\"}],\"ss\":[{\"si\":2,\"ps\":1,\"st\":1490166135023,\"et\":1490166135023,\"on\":\"Jedis/getClient\",\"ts\":{\"span.layer\":\"db\",\"component\":\"Redis\",\"db.type\":\"Redis\",\"peer.host\":\"127.0.0.1\",\"span.kind\":\"client\"},\"tb\":{},\"ti\":{\"peer.port\":6379},\"lo\":[]},{\"si\":3,\"ps\":1,\"st\":1490166135023,\"et\":1490166135023,\"on\":\"Jedis/getClient\",\"ts\":{\"span.layer\":\"db\",\"component\":\"Redis\",\"db.type\":\"Redis\",\"peer.host\":\"127.0.0.1\",\"span.kind\":\"client\"},\"tb\":{},\"ti\":{\"peer.port\":6379},\"lo\":[]},{\"si\":4,\"ps\":1,\"st\":1490166135023,\"et\":1490166135023,\"on\":\"Jedis/isConnected\",\"ts\":{\"span.layer\":\"db\",\"component\":\"Redis\",\"db.type\":\"Redis\",\"peer.host\":\"127.0.0.1\",\"span.kind\":\"client\"},\"tb\":{},\"ti\":{\"peer.port\":6379},\"lo\":[]},{\"si\":5,\"ps\":1,\"st\":1490166135023,\"et\":1490166135024,\"on\":\"Jedis/ping\",\"ts\":{\"span.layer\":\"db\",\"component\":\"Redis\",\"db.type\":\"Redis\",\"peer.host\":\"127.0.0.1\",\"span.kind\":\"client\"},\"tb\":{},\"ti\":{\"peer.port\":6379},\"lo\":[]},{\"si\":6,\"ps\":1,\"st\":1490166135024,\"et\":1490166135024,\"on\":\"Jedis/set\",\"ts\":{\"span.layer\":\"db\",\"component\":\"Redis\",\"db.type\":\"Redis\",\"peer.host\":\"127.0.0.1\",\"span.kind\":\"client\",\"db.statement\":\"set test_NEW\"},\"tb\":{},\"ti\":{\"peer.port\":6379},\"lo\":[]},{\"si\":7,\"ps\":1,\"st\":1490166135025,\"et\":1490166135025,\"on\":\"H2/JDBI/PreparedStatement/executeUpdate\",\"ts\":{\"db.instance\":\"dataSource\",\"span.layer\":\"db\",\"db.type\":\"sql\",\"component\":\"H2\",\"span.kind\":\"client\",\"db.statement\":\"INSERT INTO CACHE_TABLE(CACHE_VALUE, CACHE_KEY) VALUES(?, ?)\",\"peer.host\":\"localhost\"},\"tb\":{},\"ti\":{\"peer.port\":-1},\"lo\":[]},{\"si\":8,\"ps\":1,\"st\":1490166135026,\"et\":1490166135026,\"on\":\"H2/JDBI/Connection/close\",\"ts\":{\"db.instance\":\"dataSource\",\"span.layer\":\"db\",\"db.type\":\"sql\",\"component\":\"H2\",\"span.kind\":\"client\",\"db.statement\":\"\",\"peer.host\":\"localhost\"},\"tb\":{},\"ti\":{\"peer.port\":-1},\"lo\":[]},{\"si\":1,\"ps\":0,\"st\":0,\"et\":1490166135026,\"on\":\"Motan_default_rpc_com.a.eye.skywalking.test.cache.CacheService.updateCache(java.lang.String,java.lang.String)\",\"ts\":{\"requestId\":\"1562552445196828678\"},\"tb\":{},\"ti\":{},\"lo\":[]},{\"si\":0,\"ps\":-1,\"st\":1490166135023,\"et\":1490166135026,\"on\":\"com.a.eye.skywalking.test.cache.CacheService.updateCache(java.lang.String,java.lang.String)\",\"ts\":{\"span.layer\":\"rpc\",\"component\":\"Motan\",\"span.kind\":\"server\"},\"tb\":{},\"ti\":{},\"lo\":[]}],\"ac\":\"cache-service\",\"gt\":[\"Trace.1490166134989.142811427.45029.64.2\"]}]";
private String sample2 = "[{\"ts\":\"Segment.1490166135008.-790808105.45019.39.1\",\"st\":1490166135008,\"et\":1490166135014,\"rs\":[{\"ts\":\"Segment.1490166134989.142811427.45029.64.1\",\"si\":4,\"ac\":\"portal-service\",\"ph\":\"10.128.35.80:20880\"}],\"ss\":[{\"si\":2,\"ps\":1,\"st\":1490166135010,\"et\":1490166135010,\"on\":\"Mysql/JDBI/PreparedStatement/executeQuery\",\"ts\":{\"db.instance\":\"skywalking-test\",\"span.layer\":\"db\",\"db.type\":\"sql\",\"component\":\"Mysql\",\"span.kind\":\"client\",\"db.statement\":\"SELECT * FROM information_schema.tables WHERE table_schema \\u003d ? AND table_name \\u003d ? LIMIT 1;\",\"peer.host\":\"127.0.0.1\"},\"tb\":{},\"ti\":{\"peer.port\":3307},\"lo\":[]},{\"si\":3,\"ps\":1,\"st\":1490166135012,\"et\":1490166135013,\"on\":\"Mysql/JDBI/PreparedStatement/executeQuery\",\"ts\":{\"db.instance\":\"skywalking-test\",\"span.layer\":\"db\",\"db.type\":\"sql\",\"component\":\"Mysql\",\"span.kind\":\"client\",\"db.statement\":\"SELECT id, CACHE_KEY, CACHE_VALUE FROM CACHE_TABLE WHERE CACHE_KEY\\u003d ?\",\"peer.host\":\"127.0.0.1\"},\"tb\":{},\"ti\":{\"peer.port\":3307},\"lo\":[]},{\"si\":1,\"ps\":0,\"st\":1490166135009,\"et\":1490166135013,\"on\":\"com.a.eye.skywalking.test.persistence.PersistenceService.query(String)\",\"ts\":{\"span.layer\":\"rpc\",\"component\":\"Dubbo\",\"peer.host\":\"10.128.35.80\",\"span.kind\":\"server\",\"url\":\"rest://10.128.35.80:20880/com.a.eye.skywalking.test.persistence.PersistenceService.query(String)\"},\"tb\":{},\"ti\":{\"peer.port\":20880},\"lo\":[]},{\"si\":0,\"ps\":-1,\"st\":1490166135008,\"et\":1490166135014,\"on\":\"/persistence/query\",\"ts\":{\"span.layer\":\"http\",\"component\":\"Tomcat\",\"peer.host\":\"10.128.35.80\",\"span.kind\":\"server\",\"url\":\"http://10.128.35.80:20880/persistence/query\"},\"tb\":{},\"ti\":{\"peer.port\":61968,\"status_code\":200},\"lo\":[]}],\"ac\":\"persistence-service\",\"gt\":[\"Trace.1490166134989.142811427.45029.64.2\"]}]";
private String sample3 = "[{\"ts\":\"Segment.1490166134989.142811427.45029.64.1\",\"st\":1490166134989,\"et\":1490166135028,\"ss\":[{\"si\":2,\"ps\":1,\"st\":1490166134992,\"et\":1490166134996,\"on\":\"com.a.eye.skywalking.test.cache.CacheService.findCache(java.lang.String)\",\"ts\":{\"span.layer\":\"rpc\",\"peer.host\":\"127.0.0.1\",\"component\":\"Motan\",\"span.kind\":\"client\",\"url\":\"motan://127.0.0.1:8002/default_rpc/com.a.eye.skywalking.test.cache.CacheService/1.0/referer\"},\"tb\":{},\"ti\":{\"peer.port\":8002},\"lo\":[]},{\"si\":1,\"ps\":0,\"st\":0,\"et\":1490166134996,\"on\":\"Motan_default_rpc_com.a.eye.skywalking.test.cache.CacheService.findCache(java.lang.String)\",\"ts\":{\"requestId\":\"1562552445165371397\"},\"tb\":{},\"ti\":{},\"lo\":[]},{\"si\":4,\"ps\":3,\"st\":1490166134997,\"et\":1490166135019,\"on\":\"/persistence/query\",\"ts\":{\"span.layer\":\"http\",\"peer.host\":\"10.128.35.80\",\"component\":\"HttpClient\",\"span.kind\":\"client\",\"url\":\"http://10.128.35.80:20880/persistence/query\"},\"tb\":{},\"ti\":{\"peer.port\":20880,\"status_code\":200},\"lo\":[]},{\"si\":3,\"ps\":0,\"st\":1490166134997,\"et\":1490166135022,\"on\":\"com.a.eye.skywalking.test.persistence.PersistenceService.query(String)\",\"ts\":{\"span.layer\":\"rpc\",\"component\":\"Dubbo\",\"peer.host\":\"10.128.35.80\",\"span.kind\":\"client\",\"url\":\"rest://10.128.35.80:20880/com.a.eye.skywalking.test.persistence.PersistenceService.query(String)\"},\"tb\":{},\"ti\":{\"peer.port\":20880},\"lo\":[]},{\"si\":6,\"ps\":5,\"st\":1490166135022,\"et\":1490166135026,\"on\":\"com.a.eye.skywalking.test.cache.CacheService.updateCache(java.lang.String,java.lang.String)\",\"ts\":{\"span.layer\":\"rpc\",\"peer.host\":\"127.0.0.1\",\"component\":\"Motan\",\"span.kind\":\"client\",\"url\":\"motan://127.0.0.1:8002/default_rpc/com.a.eye.skywalking.test.cache.CacheService/1.0/referer\"},\"tb\":{},\"ti\":{\"peer.port\":8002},\"lo\":[]},{\"si\":5,\"ps\":0,\"st\":0,\"et\":1490166135026,\"on\":\"Motan_default_rpc_com.a.eye.skywalking.test.cache.CacheService.updateCache(java.lang.String,java.lang.String)\",\"ts\":{\"requestId\":\"1562552445196828678\"},\"tb\":{},\"ti\":{},\"lo\":[]},{\"si\":0,\"ps\":-1,\"st\":1490166134989,\"et\":1490166135028,\"on\":\"/portal/\",\"ts\":{\"span.layer\":\"http\",\"component\":\"Tomcat\",\"peer.host\":\"0:0:0:0:0:0:0:1\",\"span.kind\":\"server\",\"url\":\"http://localhost:8080/portal/\"},\"tb\":{},\"ti\":{\"peer.port\":61982,\"status_code\":200},\"lo\":[]}],\"ac\":\"portal-service\",\"gt\":[\"Trace.1490166134989.142811427.45029.64.2\"]}]";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册