diff --git a/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/node/NodeIndex.java b/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/node/NodeIndex.java index 663f0edf7..7ac335b70 100644 --- a/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/node/NodeIndex.java +++ b/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/node/NodeIndex.java @@ -15,9 +15,7 @@ public class NodeIndex extends AbstractIndex { public static final String Code = "code"; public static final String NickName = "nickName"; - public static final String Layer = "layer"; public static final String Component = "component"; - public static final String Kind = "kind"; @Override public String index() { @@ -42,18 +40,10 @@ public class NodeIndex extends AbstractIndex { .field("type", "string") .field("index", "not_analyzed") .endObject() - .startObject(Layer) - .field("type", "string") - .field("index", "not_analyzed") - .endObject() .startObject(Component) .field("type", "string") .field("index", "not_analyzed") .endObject() - .startObject(Kind) - .field("type", "string") - .field("index", "not_analyzed") - .endObject() .startObject(AGG_COLUMN) .field("type", "string") .field("index", "not_analyzed") diff --git a/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/node/analysis/AbstractNodeAnalysis.java b/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/node/analysis/AbstractNodeAnalysis.java index 9f1b3a157..fd654951f 100644 --- a/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/node/analysis/AbstractNodeAnalysis.java +++ b/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/node/analysis/AbstractNodeAnalysis.java @@ -35,14 +35,16 @@ abstract class AbstractNodeAnalysis extends RecordAnalysisMember { if (CollectionTools.isNotEmpty(spanList)) { logger.debug("node analysis span list size: %s", spanList.size()); + String id = timeSlice + Const.ID_SPLIT + segment.getApplicationCode(); + JsonObject appDataJsonObj = new JsonObject(); + appDataJsonObj.addProperty(NodeIndex.Code, segment.getApplicationCode()); + appDataJsonObj.addProperty(NodeIndex.NickName, segment.getApplicationCode()); + appDataJsonObj.addProperty(NodeIndex.Time_Slice, timeSlice); + setRecord(id, appDataJsonObj); + for (Span span : spanList) { JsonObject dataJsonObj = new JsonObject(); String kind = Tags.SPAN_KIND.get(span); - dataJsonObj.addProperty(NodeIndex.Kind, kind); - - String layer = Tags.SPAN_LAYER.get(span); - dataJsonObj.addProperty(NodeIndex.Layer, layer); - String component = Tags.COMPONENT.get(span); dataJsonObj.addProperty(NodeIndex.Component, component); @@ -50,13 +52,7 @@ abstract class AbstractNodeAnalysis extends RecordAnalysisMember { dataJsonObj.addProperty(NodeIndex.Code, code); 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); + logger.debug("span id=%s, kind=%s, component=%s, code=%s", span.getSpanId(), kind, component, code); 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()); @@ -72,8 +68,6 @@ abstract class AbstractNodeAnalysis extends RecordAnalysisMember { if (CollectionTools.isEmpty(segment.getRefs())) { JsonObject userDataJsonObj = new JsonObject(); userDataJsonObj.addProperty(NodeIndex.Code, Const.USER_CODE); - userDataJsonObj.addProperty(NodeIndex.Layer, Const.USER_CODE); - userDataJsonObj.addProperty(NodeIndex.Kind, Tags.SPAN_KIND_CLIENT); userDataJsonObj.addProperty(NodeIndex.Component, Const.USER_CODE); userDataJsonObj.addProperty(NodeIndex.NickName, Const.USER_CODE); userDataJsonObj.addProperty(NodeIndex.Time_Slice, timeSlice); diff --git a/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/node/persistence/NodeSearchWithTimeSlice.java b/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/node/persistence/NodeSearchWithTimeSlice.java index 292325cf3..23b22eaab 100644 --- a/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/node/persistence/NodeSearchWithTimeSlice.java +++ b/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/node/persistence/NodeSearchWithTimeSlice.java @@ -54,12 +54,12 @@ public class NodeSearchWithTimeSlice extends AbstractLocalSyncWorker { TopHits topHits = entry.getAggregations().get(NodeIndex.Top_One); for (SearchHit hit : topHits.getHits().getHits()) { logger.debug(" -> id [{%s}], _source [{%s}]", hit.getId(), hit.getSourceAsString()); - + JsonObject nodeObj = new JsonObject(); nodeObj.addProperty(NodeIndex.Code, (String) hit.getSource().get(NodeIndex.Code)); - nodeObj.addProperty(NodeIndex.Component, (String) hit.getSource().get(NodeIndex.Component)); - nodeObj.addProperty(NodeIndex.Layer, (String) hit.getSource().get(NodeIndex.Layer)); - nodeObj.addProperty(NodeIndex.Kind, (String) hit.getSource().get(NodeIndex.Kind)); + if (hit.getSource().containsKey(NodeIndex.Component)) { + nodeObj.addProperty(NodeIndex.Component, (String) hit.getSource().get(NodeIndex.Component)); + } nodeObj.addProperty(NodeIndex.NickName, (String) hit.getSource().get(NodeIndex.NickName)); nodeObj.addProperty(NodeIndex.Time_Slice, (Long) hit.getSource().get(NodeIndex.Time_Slice)); nodeArray.add(nodeObj); diff --git a/skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/segment/SegmentPostTestCase.java b/skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/segment/SegmentPostTestCase.java index 84937c1d3..19926be0e 100644 --- a/skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/segment/SegmentPostTestCase.java +++ b/skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/segment/SegmentPostTestCase.java @@ -100,10 +100,10 @@ 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", test); +// HttpClientTools.INSTANCE.post("http://localhost:7001/segments", sample1); +// HttpClientTools.INSTANCE.post("http://localhost:7001/segments", sample2); +// HttpClientTools.INSTANCE.post("http://localhost:7001/segments", sample3); + HttpClientTools.INSTANCE.post("http://localhost:7001/segments", 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}]";