-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
28 lines (22 loc) · 796 Bytes
/
config.go
File metadata and controls
28 lines (22 loc) · 796 Bytes
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
package tracebasedlogsampler
import (
"fmt"
"time"
)
type Config struct {
// How long to buffer trace ids. Dictates how long to wait for logs to arrive.
BufferDurationTraces string `mapstructure:"buffer_duration_traces"`
// How long to buffer logs, before checking if a trace id exists in the trace id buffer.
BufferDurationLogs string `mapstructure:"buffer_duration_logs"`
}
func (cfg *Config) Validate() error {
bufferDurationTraces, _ := time.ParseDuration(cfg.BufferDurationTraces)
if bufferDurationTraces.Minutes() <= 0 {
return fmt.Errorf("buffer_duration_traces must be greater than 0")
}
bufferDurationLogs, _ := time.ParseDuration(cfg.BufferDurationLogs)
if bufferDurationLogs <= 0 {
return fmt.Errorf("buffer_duration_logs must be greater than 0")
}
return nil
}