Skip to content
This repository has been archived by the owner on Aug 30, 2019. It is now read-only.

Compute sublayers for non root toplevel spans #384

Merged
merged 5 commits into from
Mar 1, 2018
Merged

Conversation

bmermet
Copy link

@bmermet bmermet commented Feb 26, 2018

Until now sublayers were only computed for the root span of each trace. We now compute it for all non leaf top level spans of the trace. The purpose being to fix some gaps in the data currently shown in the UI.

This is implemented by extracting all relevant subtraces in each trace and computing the sublayers for each of theses subtraces individually.

One consequence of this change is that now the complexity of computing sublayers is no longer O(s) with s the number of spans, but O(s * t) with s the number of spans and t the number of top level spans. Which may have a very significant performance impact on some pathological traces.

It has been deployed on staging and I haven't noticed any significant change on the CPU footprint from trace-agent.

@bmermet bmermet requested review from vlad-mh and ufoot February 26, 2018 16:25
@bmermet bmermet force-pushed the bmemermet/sublayers branch from b5d51fb to 466906c Compare February 27, 2018 09:08
@bmermet bmermet changed the title Compute sublayers for non root toplevel spans Compute sublayers for non root toplevel spans and do not compute metrics for non top level spans Feb 28, 2018
@bmermet bmermet force-pushed the bmemermet/sublayers branch from 0de20f4 to 0765f1c Compare February 28, 2018 10:42
@bmermet bmermet changed the title Compute sublayers for non root toplevel spans and do not compute metrics for non top level spans Compute sublayers for non root toplevel spans Feb 28, 2018
Gopkg.lock Outdated
@@ -25,7 +25,8 @@
[[projects]]
Copy link

@LotharSee LotharSee Feb 28, 2018

Choose a reason for hiding this comment

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

@gbbr updated the way we package vendors in #379

So it will need a bit of change to also commit the vendor changes. I'd suggest to make the testify upgrade an independent preliminary PR (as its diff will be noisy).

Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

Just some minor comments with regards to documentation.

model/trace.go Outdated
@@ -122,3 +122,87 @@ func (t Trace) APITrace() *APITrace {
EndTime: end,
}
}

// Subtrace represents the combination of a root and the trace consisting of all its descendant spans
Copy link
Contributor

@gbbr gbbr Feb 28, 2018

Choose a reason for hiding this comment

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

You missed a word here.

Subtrace represents the combination of a root span and the trace consisting of all its descendant spans.

Copy link
Author

Choose a reason for hiding this comment

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

model/trace.go Outdated
Trace Trace
}

// spaAndAncestors is an internal type used by ExtractTopLevelSubtraces
Copy link
Contributor

Choose a reason for hiding this comment

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

Here there is also a typo. It would be nice to explain (for devs) what this type is, in the comment, as opposed to writing that it is internal, which is obvious from the fact that it's unexported.

Copy link
Author

Choose a reason for hiding this comment

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

model/trace.go Outdated
return value
}

// ExtractTopLevelSubtraces extracts all subtraces rooted in a toplevel span
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comma at the end of this line and a period at the end of the second.

Copy link
Author

Choose a reason for hiding this comment

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

model/trace.go Outdated

visited := make(map[*Span]bool, len(t))
subtracesMap := make(map[*Span][]*Span)
next := stack{}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't feel very strongly about this but in Go it's generally nicer as:

var next stack

Which has the same outcome.

Copy link
Author

Choose a reason for hiding this comment

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

That looks nicer indeed

@bmermet bmermet force-pushed the bmemermet/sublayers branch from 0765f1c to 5409140 Compare February 28, 2018 13:35
@bmermet bmermet merged commit b0d80ec into master Mar 1, 2018
@LotharSee LotharSee deleted the bmemermet/sublayers branch March 19, 2018 13:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants