MCPcopy
hub / github.com/kopia/kopia / maybeStartMetricsPusher

Method maybeStartMetricsPusher

cli/observability_flags.go:198–238  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

196}
197
198func (c *observabilityFlags) maybeStartMetricsPusher(ctx context.Context) error {
199 if c.metricsPushAddr == "" {
200 return nil
201 }
202
203 c.stopPusher = make(chan struct{})
204 c.pusherWG.Add(1)
205
206 pusher := push.New(c.metricsPushAddr, c.metricsJob)
207
208 pusher.Gatherer(prometheus.DefaultGatherer)
209
210 for _, g := range c.metricsGroupings {
211 const nParts = 2
212
213 parts := strings.SplitN(g, ":", nParts)
214 if len(parts) != nParts {
215 return errors.New("grouping must be name:value")
216 }
217
218 name := parts[0]
219 val := parts[1]
220
221 pusher.Grouping(name, val)
222 }
223
224 if c.metricsPushUsername != "" {
225 pusher.BasicAuth(c.metricsPushUsername, c.metricsPushPassword)
226 }
227
228 if c.metricsPushFormat != "" {
229 pusher.Format(metricsPushFormats[c.metricsPushFormat])
230 }
231
232 log(ctx).Infof("starting prometheus pusher on %v every %v", c.metricsPushAddr, c.metricsPushInterval)
233 c.pushOnce(ctx, "initial", pusher)
234
235 go c.pushPeriodically(ctx, pusher)
236
237 return nil
238}
239
240func (c *observabilityFlags) maybeStartTraceExporter(ctx context.Context) error {
241 if !c.otlpTrace {

Callers 1

startMethod · 0.95

Calls 4

pushOnceMethod · 0.95
pushPeriodicallyMethod · 0.95
FormatMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected