You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
setParent and setParentSegment methods are exposed as Susbegment's API, but they have undocumented side effects. To give you two examples:
when a new Subsegment is created it updates its parent's reference counter parentSegment.incrementReferenceCount(); when subsegment is ended it will decrement that counter: parentSegment.decrementReferenceCount() . If between a Subsegment start and end we call setParentSegment(), we will increment and decrement reference counters for different parent's which is always never what we really want.
when setParent is called it only updates the parent of the current subsegment but it doesn't update the subsegments of that parent. That means that the old parent will keep the subsegment and new parent will not get the subsegment
so the actual reparenting should look sth like this:
the problem with that code is that it's not atomic, which may lead to weird issues if, for example newParent reference counter goes to 0 at the same time we are doing reparenting.
We need to either update the setParent's documentation to accomodate for that, or make reparenting safe with regards to reference counting and subsegment lists.
This is related to the workaround for #419 that I'm working on.
The text was updated successfully, but these errors were encountered:
Yes. It is a problem if you want to reparent the subsegment in this way. Instead of manually reset the parent as workaround, can you try the subsegment.close() method which will remove the current subsegment from the context so the next subsegment will pick the upper level of segment as parent?
setParent
andsetParentSegment
methods are exposed as Susbegment's API, but they have undocumented side effects. To give you two examples:parentSegment.incrementReferenceCount();
when subsegment is ended it will decrement that counter:parentSegment.decrementReferenceCount()
. If between a Subsegment start and end we call setParentSegment(), we will increment and decrement reference counters for different parent's which is always never what we really want.so the actual reparenting should look sth like this:
the problem with that code is that it's not atomic, which may lead to weird issues if, for example newParent reference counter goes to 0 at the same time we are doing reparenting.
We need to either update the setParent's documentation to accomodate for that, or make reparenting safe with regards to reference counting and subsegment lists.
This is related to the workaround for #419 that I'm working on.
The text was updated successfully, but these errors were encountered: