Skip to content

Commit 264f056

Browse files
committed
fixes
Signed-off-by: Won Jun Jang <wjang@uber.com>
1 parent 42ba40f commit 264f056

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

model/converter/json/from_domain.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,28 @@ func (fd fromDomain) convertReferences(span *model.Span, preserveParentID bool)
9797
length++
9898
}
9999
out := make([]json.Reference, 0, length)
100-
var parentRef json.Reference
101-
if span.ParentSpanID != 0 && !preserveParentID {
102-
// TODO this (wrongly) assumes that the reference type is always ChildOf
103-
parentRef = json.Reference{
104-
RefType: json.ChildOf,
105-
TraceID: json.TraceID(span.TraceID.String()),
106-
SpanID: json.SpanID(span.ParentSpanID.String()),
107-
}
108-
out = append(out, parentRef)
109-
}
100+
var parentRefAdded bool
110101
for _, ref := range span.References {
111-
// TODO if the parentRef was wrongly added as a ChildOf ref above, this could
112-
// potentially add a FollowsFrom ref and still keep the ChildOf ref
113102
newRef := json.Reference{
114103
RefType: fd.convertRefType(ref.RefType),
115104
TraceID: json.TraceID(ref.TraceID.String()),
116105
SpanID: json.SpanID(ref.SpanID.String()),
117106
}
118-
if newRef != parentRef {
119-
out = append(out, newRef)
107+
out = append(out, newRef)
108+
if newRef.TraceID == json.TraceID(span.TraceID.String()) &&
109+
newRef.SpanID == json.SpanID(span.ParentSpanID.String()) {
110+
// Check if the parent reference already exists
111+
parentRefAdded = true
120112
}
121113
}
114+
if span.ParentSpanID != 0 && !preserveParentID && !parentRefAdded {
115+
// TODO this (wrongly) assumes that the reference type is always ChildOf
116+
out = append(out, json.Reference{
117+
RefType: json.ChildOf,
118+
TraceID: json.TraceID(span.TraceID.String()),
119+
SpanID: json.SpanID(span.ParentSpanID.String()),
120+
})
121+
}
122122
return out
123123
}
124124

0 commit comments

Comments
 (0)