Skip to content

Commit

Permalink
Fix #232 Split leaf from parent nodes in the tree
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Farro <joef@uber.com>
  • Loading branch information
tiffon committed Jul 31, 2018
1 parent 96774b9 commit 485eefb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
8 changes: 4 additions & 4 deletions packages/jaeger-ui/src/model/trace-dag/DagNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import type { NodeID } from './types';

export default class DagNode<T = void> {
static getID(service: string, operation: string, parentID?: ?string): NodeID {
const name = `${service}\t${operation}`;
static getID(service: string, operation: string, hasChildren: boolean, parentID?: ?string): NodeID {
const name = `${service}\t${operation}${hasChildren ? '' : '\t__LEAF__'}`;
return parentID ? `${parentID}\n${name}` : name;
}

Expand All @@ -30,11 +30,11 @@ export default class DagNode<T = void> {
children: Set<NodeID>;
data: T;

constructor(service: string, operation: string, parentID?: ?NodeID, data: T) {
constructor(service: string, operation: string, hasChildren: boolean, parentID?: ?NodeID, data: T) {
this.service = service;
this.operation = operation;
this.parentID = parentID;
this.id = DagNode.getID(service, operation, parentID);
this.id = DagNode.getID(service, operation, hasChildren, parentID);
this.count = 0;
this.children = new Set();
this.data = data;
Expand Down
19 changes: 14 additions & 5 deletions packages/jaeger-ui/src/model/trace-dag/TraceDag.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export default class TraceDag<T = void> {
let key = 'a';

function pushDagNode(src: DagNode<any>) {
const node = dt._getDagNode(src.service, src.operation, src.parentID, { a: 0, b: 0 });
const node = dt._getDagNode(src.service, src.operation, src.children.size > 0, src.parentID, {
a: 0,
b: 0,
});
const { data } = node;
data[key] = src.count;
node.count = data.b - data.a;
Expand Down Expand Up @@ -67,13 +70,19 @@ export default class TraceDag<T = void> {
[...this.denseTrace.rootIDs].forEach(id => this._addDenseSpan(id, null, data));
}

_getDagNode(service: string, operation: string, parentID?: ?NodeID, data: T): DagNode<T> {
const nodeID = DagNode.getID(service, operation, parentID);
_getDagNode(
service: string,
operation: string,
hasChildren: boolean,
parentID?: ?NodeID,
data: T
): DagNode<T> {
const nodeID = DagNode.getID(service, operation, hasChildren, parentID);
let node = this.nodesMap.get(nodeID);
if (node) {
return node;
}
node = new DagNode(service, operation, parentID, data);
node = new DagNode(service, operation, hasChildren, parentID, data);
this.nodesMap.set(nodeID, node);
if (!parentID) {
this.rootIDs.add(nodeID);
Expand All @@ -95,7 +104,7 @@ export default class TraceDag<T = void> {
const { children, operation, service, skipToChild } = denseSpan;
let nodeID: ?string = null;
if (!skipToChild) {
const node = this._getDagNode(service, operation, parentNodeID, data);
const node = this._getDagNode(service, operation, children.size > 0, parentNodeID, data);
node.count++;
nodeID = node.id;
} else {
Expand Down

0 comments on commit 485eefb

Please sign in to comment.