-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
helper_test.go
75 lines (58 loc) · 1.21 KB
/
helper_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package tracer_test
import (
"context"
. "github.com/kamilsk/tracer"
)
//go:noinline
func callerA() CallerInfo {
return Caller(2)
}
func callerB() CallerInfo {
return callerA()
}
func callerC() CallerInfo {
return func() CallerInfo {
return Caller(2)
}()
}
func traceRoot(ctx context.Context) {
call := Fetch(ctx).Start("root")
defer call.Stop()
call.Checkpoint("checkpointA")
traceA(ctx)
call.Checkpoint("checkpointB")
traceB(ctx)
}
func traceA(ctx context.Context) {
call := Fetch(ctx).Start("A")
defer call.Stop()
call.Checkpoint("checkpointA1")
traceA1(ctx)
call.Checkpoint("checkpointA2")
traceA2(ctx)
}
func traceA1(ctx context.Context) {
defer Fetch(ctx).Start().Stop()
func(ctx context.Context) {
defer Fetch(ctx).Start().Stop()
}(ctx)
}
func traceA2(ctx context.Context) {
defer Fetch(ctx).Start().Stop()
}
func traceB(ctx context.Context) {
call := Fetch(ctx).Start("B")
defer call.Stop()
call.Checkpoint("checkpointB1")
traceB1(ctx)
call.Checkpoint("checkpointB2")
func(ctx context.Context) {
defer Fetch(ctx).Start().Stop()
}(ctx)
}
func traceB1(ctx context.Context) {
defer Fetch(ctx).Start().Stop()
func(ctx context.Context) {
defer Fetch(ctx).Start().Stop()
}(ctx)
}