-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
61 lines (48 loc) · 1018 Bytes
/
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
54
55
56
57
58
59
60
61
package main
import (
"errors"
)
type Config struct {
AggrIntervalSec int `toml:"aggrIntervalSec"`
Addr string
Source string
SendBatchSize int
SendMaxIntervaSec int
SendMaxRetryCount int
SendTimeoutSec int
MetricGCIntervalSec int
MetricGCSec int
}
func (c *Config) ConfigValidate() error {
if c == nil {
return errors.New("config of tracer can't be nil")
}
if c.Addr == "" {
return errors.New("addr of tracer can't be nil")
}
if c.AggrIntervalSec == 0 {
c.AggrIntervalSec = 60
}
if c.Source == "" {
c.Source = "init etracer"
}
if c.SendBatchSize == 0 {
c.SendBatchSize = 1000
}
if c.SendMaxIntervaSec == 0 {
c.SendMaxIntervaSec = 10
}
if c.SendMaxRetryCount == 0 {
c.SendMaxRetryCount = 3
}
if c.SendTimeoutSec == 0 {
c.SendTimeoutSec = 5
}
if c.MetricGCSec == 0 {
c.MetricGCSec = 180 // 3min by default
}
if c.MetricGCIntervalSec == 0 {
c.MetricGCIntervalSec = 60 // 1min by default
}
return nil
}