-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(trace-tree-node): Consolidating node methods and overrides #101174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: abdk/trace-from-spans
Are you sure you want to change the base?
feat(trace-tree-node): Consolidating node methods and overrides #101174
Conversation
get id(): string { | ||
const firstChild = this.children[0]; | ||
return firstChild?.id; | ||
return firstChild?.id ?? uuid4(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Node ID Unstability Causes Functionality Failures
The id
getters in RootNode
, ParentAutogroupNode
, and SiblingAutogroupNode
use uuid4()
. This generates a new UUID on every access, making node IDs unstable. This breaks functionality relying on consistent identifiers, such as node identification, path matching, and caching.
Additional Locations (2)
return false; | ||
} | ||
return this.matchById(id); | ||
return this.id === id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
} | ||
|
||
get id(): string | undefined { | ||
return this.value && 'event_id' in this.value ? this.value.event_id : undefined; | ||
} | ||
|
||
get op(): string | undefined { | ||
return this.value && 'op' in this.value ? this.value.op : undefined; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential bug: Call to non-existent static method causes runtime TypeError
-
Description: A call to a non-existent static method
TraceTree.DirectVisibleChildren
will cause a runtimeTypeError
. The refactoring introduced an instance propertynode.directVisibleChildren
but failed to update this specific call site. This will cause a crash when the trace waterfall attempts to display the children count for span rows. -
Suggested fix: Replace the static method call
TraceTree.DirectVisibleChildren(node).length
with the instance propertynode.directVisibleChildren.length
.
severity: 3.0, confidence: 5.0
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! The only concern I have is the uuid4()
issue that Cursor already pointed out
get id(): string | undefined { | ||
return this.head.id ?? this.tail.id; | ||
get id(): string { | ||
return this.head.id ?? this.tail.id ?? uuid4(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀 maybe better to use uuid4()
at construction time, so it's stable?
canShowDetails = false; | ||
|
||
get id(): string { | ||
return uuid4(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same uuid4()
note as above
Every node needs to consciously be assigned an
id
. Helps prevent needing overrides on methods likepathToNode
that are derived fromid
-> Madeid
an abstract getter.Nodes with special hierarchy like
parentAutogroupNode
, should only be concerned about theirnode.directVisibleChildren
, and how it changes when it's expanded state is toggled. Prevents having to override more generic methods likenode.visibleChildren
that return all embedded visible children under a node -> Renamednode.directChildren
tonode.directVisibleChildren
and it respects the expanded state. Removed node.visibleChildren overrides. Much cleaner implementation.Removed redundant
node.matchByPath
overrides. Nodes won't match anyways, unless the correct path prefix is passed tobaseNode.matchByPath
. The prefix is determined bynode.path
that uses the node's specific type and id.Cleaned up typescript errors from tests, since we no longer need to pass tree static methods down to
transactionNodes
.