|
|
@@ -18,10 +18,6 @@ import (
|
|
18
|
18
|
|
|
19
|
19
|
type Proxy struct {
|
|
20
|
20
|
base
|
|
21
|
|
-
|
|
22
|
|
- prometheusListener net.Listener
|
|
23
|
|
- prometheus *stats.PrometheusFactory
|
|
24
|
|
- statsdFactory *stats.StatsdFactory
|
|
25
|
21
|
}
|
|
26
|
22
|
|
|
27
|
23
|
func (c *Proxy) Run(cli *CLI, version string) error {
|
|
|
@@ -32,7 +28,7 @@ func (c *Proxy) Run(cli *CLI, version string) error {
|
|
32
|
28
|
return c.Execute()
|
|
33
|
29
|
}
|
|
34
|
30
|
|
|
35
|
|
-func (c *Proxy) Execute() error { // nolint: funlen
|
|
|
31
|
+func (c *Proxy) Execute() error {
|
|
36
|
32
|
zerolog.TimeFieldFormat = zerolog.TimeFormatUnixMs
|
|
37
|
33
|
zerolog.TimestampFieldName = "timestamp"
|
|
38
|
34
|
zerolog.LevelFieldName = "level"
|
|
|
@@ -59,10 +55,6 @@ func (c *Proxy) Execute() error { // nolint: funlen
|
|
59
|
55
|
PreferIP: c.Config.PreferIP.Value(mtglib.DefaultPreferIP),
|
|
60
|
56
|
}
|
|
61
|
57
|
|
|
62
|
|
- if opts.Concurrency == 0 {
|
|
63
|
|
- opts.Concurrency = mtglib.DefaultConcurrency
|
|
64
|
|
- }
|
|
65
|
|
-
|
|
66
|
58
|
opts.Logger.BindStr("configuration", c.Config.String()).Debug("configuration")
|
|
67
|
59
|
|
|
68
|
60
|
c.setupAntiReplayCache(&opts)
|
|
|
@@ -89,20 +81,8 @@ func (c *Proxy) Execute() error { // nolint: funlen
|
|
89
|
81
|
go proxy.Serve(listener) // nolint: errcheck
|
|
90
|
82
|
|
|
91
|
83
|
<-ctx.Done()
|
|
92
|
|
-
|
|
93
|
84
|
listener.Close()
|
|
94
|
|
-
|
|
95
|
|
- if c.prometheusListener != nil {
|
|
96
|
|
- c.prometheusListener.Close()
|
|
97
|
|
- }
|
|
98
|
|
-
|
|
99
|
|
- if c.prometheus != nil {
|
|
100
|
|
- c.prometheus.Close()
|
|
101
|
|
- }
|
|
102
|
|
-
|
|
103
|
|
- if c.statsdFactory != nil {
|
|
104
|
|
- c.statsdFactory.Close()
|
|
105
|
|
- }
|
|
|
85
|
+ proxy.Shutdown()
|
|
106
|
86
|
|
|
107
|
87
|
return nil
|
|
108
|
88
|
}
|
|
|
@@ -173,8 +153,6 @@ func (c *Proxy) setupEventStream(opts *mtglib.ProxyOpts) error {
|
|
173
|
153
|
return fmt.Errorf("cannot build statsd observer: %w", err)
|
|
174
|
154
|
}
|
|
175
|
155
|
|
|
176
|
|
- c.statsdFactory = &statsdFactory
|
|
177
|
|
-
|
|
178
|
156
|
factories = append(factories, statsdFactory.Make)
|
|
179
|
157
|
}
|
|
180
|
158
|
|
|
|
@@ -191,9 +169,6 @@ func (c *Proxy) setupEventStream(opts *mtglib.ProxyOpts) error {
|
|
191
|
169
|
|
|
192
|
170
|
go prometheus.Serve(listener) // nolint: errcheck
|
|
193
|
171
|
|
|
194
|
|
- c.prometheusListener = listener
|
|
195
|
|
- c.prometheus = prometheus
|
|
196
|
|
-
|
|
197
|
172
|
factories = append(factories, prometheus.Make)
|
|
198
|
173
|
}
|
|
199
|
174
|
|