Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
- Add default non-root user in the Docker image. ([#593](https://github.com/getsentry/vroom/pull/593))
- Classify macOS frames from an application as application frames. ([#604](https://github.com/getsentry/vroom/pull/604))
- Return number of occurrences in flamegraph. ([#622](https://github.com/getsentry/vroom/pull/622), [#625](https://github.com/getsentry/vroom/pull/625))
- Use function duration when computing metrics ([#627](https://github.com/getsentry/vroom/pull/627), [#628](https://github.com/getsentry/vroom/pull/628), [#629](https://github.com/getsentry/vroom/pull/629), [#630](https://github.com/getsentry/vroom/pull/630))
- Use function duration when computing metrics ([#627](https://github.com/getsentry/vroom/pull/627), [#628](https://github.com/getsentry/vroom/pull/628), [#629](https://github.com/getsentry/vroom/pull/629), [#630](https://github.com/getsentry/vroom/pull/630), [#639](https://github.com/getsentry/vroom/pull/639))
- Remove Unused metrics endpoint ([#633](https://github.com/getsentry/vroom/pull/633))

**Bug Fixes**:
Expand Down
7 changes: 7 additions & 0 deletions internal/chunk/sample_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestCallTrees(t *testing.T) {
"1": {
{
DurationNS: 40_000_000,
DurationsNS: []uint64{40_000_000},
EndNS: 50_000_000,
Fingerprint: 15444731332182868858,
IsApplication: true,
Expand All @@ -52,6 +53,7 @@ func TestCallTrees(t *testing.T) {
Children: []*nodetree.Node{
{
DurationNS: 40_000_000,
DurationsNS: []uint64{40_000_000},
EndNS: 50_000_000,
StartNS: 10_000_000,
Fingerprint: 14164357600995800812,
Expand All @@ -64,6 +66,7 @@ func TestCallTrees(t *testing.T) {
Children: []*nodetree.Node{
{
DurationNS: 10_000_000,
DurationsNS: []uint64{10_000_000},
EndNS: 50_000_000,
Fingerprint: 9531802423075301657,
IsApplication: true,
Expand Down Expand Up @@ -104,6 +107,7 @@ func TestCallTrees(t *testing.T) {
"1": {
{
DurationNS: 30_000_000,
DurationsNS: []uint64{30_000_000},
EndNS: 40_000_000,
Fingerprint: 15444731332182868858,
IsApplication: true,
Expand All @@ -116,6 +120,7 @@ func TestCallTrees(t *testing.T) {
Children: []*nodetree.Node{
{
DurationNS: 30_000_000,
DurationsNS: []uint64{30_000_000},
EndNS: 40_000_000,
Fingerprint: 14164357600995800812,
IsApplication: true,
Expand Down Expand Up @@ -156,6 +161,7 @@ func TestCallTrees(t *testing.T) {
"1": {
{
DurationNS: 10_000_000,
DurationsNS: []uint64{10_000_000},
EndNS: 20_000_000,
Fingerprint: 15444731332182868858,
IsApplication: true,
Expand All @@ -168,6 +174,7 @@ func TestCallTrees(t *testing.T) {
},
{
DurationNS: 10_000_000,
DurationsNS: []uint64{10_000_000},
EndNS: 30_000_000,
Fingerprint: 15444731332182868859,
IsApplication: true,
Expand Down
22 changes: 20 additions & 2 deletions internal/flamegraph/flamegraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func addCallTreeToFlamegraph(flamegraphTree *[]*nodetree.Node, callTree []*nodet
currentNode.Occurrence += node.Occurrence
currentNode.SampleCount += node.SampleCount
currentNode.DurationNS += node.DurationNS
currentNode.SelfTimeNS += node.SelfTimeNS
currentNode.DurationsNS = append(currentNode.DurationsNS, node.DurationsNS...)
} else {
currentNode = node.ShallowCopyWithoutChildren()
*flamegraphTree = append(*flamegraphTree, currentNode)
Expand Down Expand Up @@ -186,6 +188,16 @@ func toSpeedscope(
fd.visitCalltree(tree, &stack)
}

for i, frameInfo := range fd.frameInfos {
sort.Slice(frameInfo.DurationsNS, func(i, j int) bool {
return frameInfo.DurationsNS[i] < frameInfo.DurationsNS[j]
})
frameInfo.P75Duration, _ = metrics.Quantile(frameInfo.DurationsNS, 0.75)
frameInfo.P95Duration, _ = metrics.Quantile(frameInfo.DurationsNS, 0.95)
frameInfo.P99Duration, _ = metrics.Quantile(frameInfo.DurationsNS, 0.99)
fd.frameInfos[i] = frameInfo
}

s.SetData("total_samples", fd.totalSamples)
s.SetData("final_samples", fd.Len())

Expand Down Expand Up @@ -228,6 +240,9 @@ func (f *flamegraph) visitCalltree(node *nodetree.Node, currentStack *[]int) {
*currentStack = append(*currentStack, i)
f.frameInfos[i].Count += node.Occurrence
f.frameInfos[i].Weight += node.DurationNS
f.frameInfos[i].SumDuration += node.DurationNS
f.frameInfos[i].SumSelfTime += node.SelfTimeNS
f.frameInfos[i].DurationsNS = append(f.frameInfos[i].DurationsNS, node.DurationsNS...)
} else {
frame := node.ToFrame()
sfr := speedscope.Frame{
Expand All @@ -245,8 +260,11 @@ func (f *flamegraph) visitCalltree(node *nodetree.Node, currentStack *[]int) {
*currentStack = append(*currentStack, len(f.frames))
f.frames = append(f.frames, sfr)
f.frameInfos = append(f.frameInfos, speedscope.FrameInfo{
Count: node.Occurrence,
Weight: node.DurationNS,
Count: node.Occurrence,
Weight: node.DurationNS,
SumDuration: node.DurationNS,
SumSelfTime: node.SelfTimeNS,
DurationsNS: node.DurationsNS,
})
}

Expand Down
Loading