Skip to content

Commit

Permalink
Merge pull request #426 from getsentry/txiao/fix/count-method-enters-…
Browse files Browse the repository at this point in the history
…correctly

fix(android): Count method enters correctly
  • Loading branch information
Zylphrex authored Mar 12, 2024
2 parents 300f7d7 + a628f84 commit 4ff40d4
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

- Label all node frames as system ([#392](https://github.com/getsentry/vroom/pull/392))
- Fix react-native (android) rendering issue ([#397](https://github.com/getsentry/vroom/pull/397))
- Restrict max depth for android profiles ([#424](https://github.com/getsentry/vroom/pull/424))
- Restrict max depth for android profiles ([#424](https://github.com/getsentry/vroom/pull/424)), ([#426](https://github.com/getsentry/vroom/pull/426))

**Internal**:

Expand Down
2 changes: 1 addition & 1 deletion internal/profile/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ func (p Android) CallTreesWithMaxDepth(maxDepth int) map[uint64][]*nodetree.Node

switch e.Action {
case EnterAction:
enterPerMethod[e.MethodID]++
m, exists := methods[e.MethodID]
if !exists {
methods[e.MethodID] = AndroidMethod{
Expand All @@ -299,6 +298,7 @@ func (p Android) CallTreesWithMaxDepth(maxDepth int) map[uint64][]*nodetree.Node
if stackDepth[e.ThreadID] > maxDepth {
continue
}
enterPerMethod[e.MethodID]++
n := nodetree.NodeFromFrame(m.Frame(), ts, 0, 0)
if len(stacks[e.ThreadID]) == 0 {
treesByThreadID[e.ThreadID] = append(treesByThreadID[e.ThreadID], n)
Expand Down
112 changes: 111 additions & 1 deletion internal/profile/android_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,116 @@ var (
},
},
}
stackDepth3EventsTrace = Android{
Clock: "Dual",
Events: []AndroidEvent{
{
Action: "Enter",
ThreadID: 1,
MethodID: 1,
Time: EventTime{
Monotonic: EventMonotonic{
Wall: Duration{
Nanos: 1000,
},
},
},
},
{
Action: "Enter",
ThreadID: 1,
MethodID: 3,
Time: EventTime{
Monotonic: EventMonotonic{
Wall: Duration{
Nanos: 1000,
},
},
},
},
{
Action: "Enter",
ThreadID: 1,
MethodID: 4,
Time: EventTime{
Monotonic: EventMonotonic{
Wall: Duration{
Nanos: 1000,
},
},
},
},
{
Action: "Exit",
ThreadID: 1,
MethodID: 2,
Time: EventTime{
Monotonic: EventMonotonic{
Wall: Duration{
Nanos: 2000,
},
},
},
},
{
Action: "Exit",
ThreadID: 1,
MethodID: 4,
Time: EventTime{
Monotonic: EventMonotonic{
Wall: Duration{
Nanos: 2000,
},
},
},
},
{
Action: "Exit",
ThreadID: 1,
MethodID: 3,
Time: EventTime{
Monotonic: EventMonotonic{
Wall: Duration{
Nanos: 2000,
},
},
},
},
},
Methods: []AndroidMethod{
{
ClassName: "class1",
ID: 1,
Name: "method1",
Signature: "()",
},
{
ClassName: "class2",
ID: 2,
Name: "method2",
Signature: "()",
},
{
ClassName: "class3",
ID: 3,
Name: "method3",
Signature: "()",
},
{
ClassName: "class4",
ID: 4,
Name: "method4",
Signature: "()",
},
},
StartTime: 398635355383000,
Threads: []AndroidThread{
{
ID: 1,
Name: "main",
},
},
}
)

func TestSpeedscope(t *testing.T) {
Expand Down Expand Up @@ -565,7 +675,7 @@ func TestCallTrees(t *testing.T) {
},
{
name: "Build call trees but truncate stack depth",
trace: missingExitEventsTrace,
trace: stackDepth3EventsTrace,
want: map[uint64][]*nodetree.Node{
1: {
{
Expand Down

0 comments on commit 4ff40d4

Please sign in to comment.