Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
21 changes: 14 additions & 7 deletions model/converter/json/from_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,26 @@ func (fd fromDomain) convertReferences(span *model.Span, preserveParentID bool)
length++
}
out := make([]json.Reference, 0, length)
if span.ParentSpanID != 0 && !preserveParentID {
out = append(out, json.Reference{
RefType: json.ChildOf,
TraceID: json.TraceID(span.TraceID.String()),
SpanID: json.SpanID(span.ParentSpanID.String()),
})
}
var parentRefAdded bool
for _, ref := range span.References {
out = append(out, json.Reference{
RefType: fd.convertRefType(ref.RefType),
TraceID: json.TraceID(ref.TraceID.String()),
SpanID: json.SpanID(ref.SpanID.String()),
})
if ref.TraceID == span.TraceID && ref.SpanID == span.ParentSpanID {
// Check if the parent reference already exists
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.

not sure this comment explains anything, maybe remove it?

parentRefAdded = true
}
}
if span.ParentSpanID != 0 && !preserveParentID && !parentRefAdded {
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.

not directly related to this diff, but I see that the only time preserveParentID == true happens is when this conversion is called from ES storage WriteSpan function. What was the reason why we needed to preserve ParentSpanID in ES? Same performance/storage optimization?

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.

don't recall the exact reason but it probably has to do with keeping the es schema the same as the zipkin one.

// By this point, if ParentSpanID != 0 but there are no other references,
// then the ParentSpanID does refer to child-of type
out = append(out, json.Reference{
RefType: json.ChildOf,
TraceID: json.TraceID(span.TraceID.String()),
SpanID: json.SpanID(span.ParentSpanID.String()),
})
}
return out
}
Expand Down