-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
53 lines (43 loc) · 1.06 KB
/
config.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
package tracer
import (
"github.com/k0kubun/pp"
"github.com/rai-project/config"
"github.com/rai-project/vipertags"
)
type tracerConfig struct {
Enabled bool `json:"enabled" config:"tracer.enabled" default:"true"`
Provider string `json:"provider" config:"tracer.provider" default:"jaeger"`
LevelString string `json:"level" config:"tracer.level"`
Level Level `json:"-" config:"-"`
done chan struct{} `json:"-" config:"-"`
}
var (
// Config holds the data read by rai-project/config
Config = &tracerConfig{
done: make(chan struct{}),
Level: NO_TRACE,
}
)
func (tracerConfig) ConfigName() string {
return "Tracer"
}
func (c *tracerConfig) SetDefaults() {
vipertags.SetDefaults(c)
}
func (c *tracerConfig) Read() {
defer close(c.done)
vipertags.Fill(c)
c.Level = LevelFromName(c.LevelString)
}
func (c tracerConfig) Wait() {
<-c.done
}
func (c tracerConfig) String() string {
return pp.Sprintln(c)
}
func (c tracerConfig) Debug() {
log.Debug("Tracer Config = ", c)
}
func init() {
config.Register(Config)
}