Skip to content

Commit

Permalink
handle follows from as parent span id
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Rydz <niechzyjetequila@gmail.com>
  • Loading branch information
kubarydz committed Apr 14, 2023
1 parent 506adaf commit c46960b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion model/adjuster/clockskew.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func (a *clockSkewAdjuster) buildNodesMap() {
func (a *clockSkewAdjuster) buildSubGraphs() {
a.roots = make(map[model.SpanID]*node)
for _, n := range a.spans {
// TODO handle FOLLOWS_FROM references
if n.span.ParentSpanID() == 0 {
a.roots[n.span.SpanID] = n
continue
Expand Down
2 changes: 1 addition & 1 deletion model/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (s *Span) NormalizeTimestamps() {
func (s *Span) ParentSpanID() SpanID {
for i := range s.References {
ref := &s.References[i]
if ref.TraceID == s.TraceID && ref.RefType == ChildOf {
if ref.TraceID == s.TraceID && (ref.RefType == ChildOf || ref.RefType == FollowsFrom) {
return ref.SpanID
}
}
Expand Down
4 changes: 4 additions & 0 deletions model/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ func TestParentSpanID(t *testing.T) {

span.References = []model.SpanRef{
model.NewFollowsFromRef(span.TraceID, model.NewSpanID(777)),
}
assert.Equal(t, model.NewSpanID(777), span.ParentSpanID())

span.References = []model.SpanRef{
model.NewChildOfRef(span.TraceID, model.NewSpanID(888)),
}
assert.Equal(t, model.NewSpanID(888), span.ParentSpanID())
Expand Down

0 comments on commit c46960b

Please sign in to comment.