...
1 package metrics
2
3 import "github.com/prometheus/client_golang/prometheus"
4
5
6
7 type Option func(*options)
8
9
10
11 func WithCollectors(c ...prometheus.Collector) Option {
12 return func(o *options) {
13 o.customCollectors = c
14 }
15 }
16
17
18
19 func WithSuspend() Option {
20 return func(o *options) {
21 o.suspend = true
22 }
23 }
24
25
26 func WithReason() Option {
27 return func(o *options) {
28 o.reason = true
29 }
30 }
31
32 type options struct {
33
34 suspend bool
35
36 reason bool
37 customCollectors []prometheus.Collector
38 }
39
40 func makeOptions(opts ...Option) *options {
41 o := &options{customCollectors: []prometheus.Collector{}}
42 for _, opt := range opts {
43 opt(o)
44 }
45
46 return o
47 }
48
View as plain text