This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch feature/5.0.0
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking-ui.git

commit 6a589cfeeb9315bef65522ae995bca4786ea2ca8
Author: hanahmily <hanahm...@gmail.com>
AuthorDate: Wed Feb 14 16:49:49 2018 +0800

    Add MQ trace feature
---
 src/main/frontend/mock/trace.js                    | 57 ++++++++++++++++++++++
 .../frontend/src/components/TraceStack/index.js    | 41 ++++++++++++++--
 2 files changed, 95 insertions(+), 3 deletions(-)

diff --git a/src/main/frontend/mock/trace.js b/src/main/frontend/mock/trace.js
index d6c8269..2376cbe 100644
--- a/src/main/frontend/mock/trace.js
+++ b/src/main/frontend/mock/trace.js
@@ -36,6 +36,7 @@ export default {
             spans: [
               {
                 spanId: 1,
+                segmentId: 1,
                 startTime: 1516151345000,
                 applicationCode: 'xx',
                 endTime: 1516151355000,
@@ -49,6 +50,7 @@ export default {
               {
                 spanId: 2,
                 parentSpanId: 1,
+                segmentId: 1,
                 applicationCode: 'yy',
                 startTime: 1516151348000,
                 endTime: 1516151351000,
@@ -61,6 +63,7 @@ export default {
               {
                 spanId: 3,
                 parentSpanId: 2,
+                segmentId: 1,
                 applicationCode: 'yy',
                 startTime: 1516151349312,
                 endTime: 1516151350728,
@@ -73,6 +76,7 @@ export default {
               {
                 spanId: 4,
                 parentSpanId: 1,
+                segmentId: 1,
                 applicationCode: 'zz',
                 startTime: 1516151351000,
                 endTime: 1516151354000,
@@ -82,6 +86,59 @@ export default {
                 peer: '@ip',
                 'tags|1-5': [{ key: 'db.type', value: 'aa' }],
               },
+              {
+                spanId: 5,
+                parentSpanId: 1,
+                segmentId: 1,
+                applicationCode: 'zz',
+                startTime: 1516151351000,
+                endTime: 1516151354000,
+                operationName: '/mq/producer',
+                'type|1': ['Exit'],
+                'component|1': ['RockerMQ'],
+                peer: '@ip',
+                'tags|1-5': [{ key: 'producer', value: 'tt' }],
+              },
+              {
+                spanId: 6,
+                segmentId: 1,
+                applicationCode: 'kk',
+                startTime: 1516151355000,
+                endTime: 1516151360000,
+                operationName: '/mq/consumer',
+                'type|1': ['Entry'],
+                'component|1': ['RockerMQ'],
+                peer: '@ip',
+                'tags|1-5': [{ key: 'consumer', value: 'tt' }],
+                refs: [
+                  {
+                    parentSpanId: 5,
+                    parentSegmentId: 1,
+                  },
+                ],
+              },
+              {
+                spanId: 6,
+                segmentId: 1,
+                applicationCode: 'kk',
+                startTime: 1516151355000,
+                endTime: 1516151360000,
+                operationName: '/mq/consumer',
+                'type|1': ['Entry'],
+                'component|1': ['Kafka'],
+                peer: '@ip',
+                'tags|1-5': [{ key: 'consumer', value: 'tt' }],
+                refs: [
+                  {
+                    traceId: 121212,
+                    type: 'CROSS_PROCESS',
+                  },
+                  {
+                    traceId: 22223333,
+                    type: 'CROSS_THREAD',
+                  },
+                ],
+              },
             ],
           },
         },
diff --git a/src/main/frontend/src/components/TraceStack/index.js 
b/src/main/frontend/src/components/TraceStack/index.js
index 5515b4e..1023109 100644
--- a/src/main/frontend/src/components/TraceStack/index.js
+++ b/src/main/frontend/src/components/TraceStack/index.js
@@ -64,8 +64,9 @@ class TraceStack extends PureComponent {
     node.endTime = span.endTime;
     node.duration = span.endTime - span.startTime;
     node.content = span.operationName;
-    node.spanSegId = span.spanId;
-    node.parentSpanSegId = span.parentSpanId;
+    node.spanSegId = this.id(span.segmentId, span.spanId);
+    node.parentSpanSegId = this.findParent(span);
+    node.refs = span.refs;
     node.type = span.type;
     node.peer = span.peer;
     node.component = span.component;
@@ -80,6 +81,22 @@ class TraceStack extends PureComponent {
     }
     idMap[node.spanSegId] = nodes.length - 1;
   }
+  id = (...seg) => seg.join();
+  findParent = (span) => {
+    const { spans } = this.props;
+    if (span.refs) {
+      const ref = span.refs.find(_ => spans.findIndex(s =>
+        this.id(_.parentSegmentId, _.parentSpanId) === this.id(s.segmentId, 
s.spanId)) > -1);
+      if (ref) {
+        return this.id(ref.parentSegmentId, ref.parentSpanId);
+      }
+    }
+    const result = this.id(span.segmentId, span.parentSpanId);
+    if (spans.findIndex(s => result === this.id(s.segmentId, s.spanId)) > -1) {
+      return result;
+    }
+    return null;
+  }
   drawAxis = () => {
     const { width } = this.state;
     const { nodes, bap } = this.state;
@@ -138,7 +155,7 @@ class TraceStack extends PureComponent {
         .attr('y', (index * height) + (height / 2))
         .attr('class', styles.rectText)
         .text(content);
-      if (index > 0) {
+      if (index > 0 && positionMap[parentSpanSegId]) {
         const parentX = positionMap[parentSpanSegId].x;
         const parentY = positionMap[parentSpanSegId].y;
 
@@ -260,6 +277,23 @@ class TraceStack extends PureComponent {
         />
       </TabPane>
     )) : null;
+    const relatedTraces = span.parentSpanSegId ? null : (
+      <TabPane tab="Related Trace" key={3}>
+        <List
+          itemLayout="horizontal"
+          dataSource={span.refs}
+          renderItem={item => (
+            <List.Item>
+              <List.Item.Meta
+                size="small"
+                title={item.type}
+                description={item.traceId}
+              />
+            </List.Item>
+          )}
+        />
+      </TabPane>
+    );
     return (
       <div className={styles.stack}>
         <div style={{ paddingBottom: 10 }}>
@@ -289,6 +323,7 @@ class TraceStack extends PureComponent {
               />
             </TabPane>
             {logs}
+            {relatedTraces}
           </Tabs>
         </Modal>
       </div>

-- 
To stop receiving notification emails like this one, please contact
hanahm...@apache.org.

Reply via email to