Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions model/converter/json/fixtures/domain_01.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,27 @@
"warnings": [
"some span warning"
]
},
{
"traceID": "1",
"spanID": "5",
"parentSpanID": "4",
"operationName": "preserveParentID-test",
"references": [
{
"refType": "child-of",
"traceID": "1",
"spanID": "4"
}
],
"startTime": "2017-01-26T16:46:31.639875139-05:00",
"duration": 4000,
"process": {
"serviceName": "service-y"
},
"warnings": [
"some span warning"
]
}
],
"warnings": [
Expand Down
20 changes: 20 additions & 0 deletions model/converter/json/fixtures/ui_01.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,26 @@
"warnings": [
"some span warning"
]
},
{
"traceID": "1",
"spanID": "5",
"operationName": "preserveParentID-test",
"references": [
{
"refType": "CHILD_OF",
"traceID": "1",
"spanID": "4"
}
],
"startTime": 1485467191639875,
"duration": 4,
"tags": [],
"logs": [],
"processID": "p2",
"warnings": [
"some span warning"
]
}
],
"processes": {
Expand Down
16 changes: 12 additions & 4 deletions model/converter/json/from_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,27 @@ func (fd fromDomain) convertReferences(span *model.Span, preserveParentID bool)
length++
}
out := make([]json.Reference, 0, length)
var parentRef json.Reference
if span.ParentSpanID != 0 && !preserveParentID {
out = append(out, json.Reference{
// TODO this (wrongly) assumes that the reference type is always ChildOf
parentRef = json.Reference{
RefType: json.ChildOf,
TraceID: json.TraceID(span.TraceID.String()),
SpanID: json.SpanID(span.ParentSpanID.String()),
})
}
out = append(out, parentRef)
}
for _, ref := range span.References {
out = append(out, json.Reference{
// TODO if the parentRef was wrongly added as a ChildOf ref above, this could
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this TODO, it might be easier to keep track of parentRef but not add it until we're done with this for loop and if the reference isn't added, add it post. This way, if the reference should be a FollowsFrom, we don't double report.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want to fix it for good then?

// potentially add a FollowsFrom ref and still keep the ChildOf ref
newRef := json.Reference{
RefType: fd.convertRefType(ref.RefType),
TraceID: json.TraceID(ref.TraceID.String()),
SpanID: json.SpanID(ref.SpanID.String()),
})
}
if newRef != parentRef {
out = append(out, newRef)
}
}
return out
}
Expand Down