(ctx context.Context)
| 196 | } |
| 197 | |
| 198 | func (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 | |
| 240 | func (c *observabilityFlags) maybeStartTraceExporter(ctx context.Context) error { |
| 241 | if !c.otlpTrace { |
no test coverage detected