forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions.go
43 lines (37 loc) · 1.32 KB
/
options.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
package module
import (
"time"
"github.com/elastic/beats/metricbeat/mb"
)
// Option specifies some optional arguments used for configuring the behavior
// of a module Wrapper.
type Option func(wrapper *Wrapper)
// WithMaxStartDelay specifies the upper bound for the random startup delay
// for each MetricSet in the module. By default there is no delay.
func WithMaxStartDelay(delay time.Duration) Option {
return func(w *Wrapper) {
w.maxStartDelay = delay
}
}
// WithEventModifier attaches an EventModifier that will be executed for each
// event generated by the MetricSets of the module. Multiple EventModifiers can
// be added and they will be executed in the order in which they were added.
func WithEventModifier(modifier mb.EventModifier) Option {
return func(w *Wrapper) {
w.eventModifiers = append(w.eventModifiers, modifier)
}
}
// WithMetricSetInfo attaches an EventModifier that adds information about the
// MetricSet that generated the event. It will always add the metricset and
// module names. And it will add the host and rtt (round-trip time in
// microseconds) values if they are non-zero values.
//
// "metricset": {
// "host": "apache",
// "module": "apache",
// "name": "status",
// "rtt": 115
// }
func WithMetricSetInfo() Option {
return WithEventModifier(mb.AddMetricSetInfo)
}