forked from didi/sharingan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag_with_recorder.go
46 lines (35 loc) · 979 Bytes
/
tag_with_recorder.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
// +build recorder
package sharingan
import (
"log"
"os"
"github.com/light-pan/sharingan/plugins"
"github.com/light-pan/sharingan/recorder"
"github.com/light-pan/sharingan/recorder/koala/hook"
"github.com/light-pan/sharingan/recorder/koala/logger"
"github.com/light-pan/sharingan/recorder/koala/sut"
)
// GetCurrentGoRoutineID get current goroutineID incase SetDelegatedFromGoRoutineID
func GetCurrentGoRoutineID() int64 {
return recorder.GetCurrentGoRoutineID()
}
// SetDelegatedFromGoRoutineID should be used when this goroutine is doing work for another goroutine
func SetDelegatedFromGoRoutineID(gID int64) {
recorder.SetDelegatedFromGoRoutineID(gID)
}
func init() {
if os.Getenv("RECORDER_ENABLED") != "true" {
return
}
// init logger
logger.Init()
// init plugin && start recorder
plugins.InitRecorderPlugin()
plugins.StartRecorder()
// start hook
hook.Start()
// start gc
sut.StartGC()
// log
log.Println("mode", "=====recorder=====")
}