(ctx context.Context)
| 268 | } |
| 269 | |
| 270 | func (c *observabilityFlags) stop(ctx context.Context) { |
| 271 | if c.dumpAllocatorStats { |
| 272 | gather.DumpStats(ctx) |
| 273 | } |
| 274 | |
| 275 | if c.stopPusher != nil { |
| 276 | close(c.stopPusher) |
| 277 | |
| 278 | c.pusherWG.Wait() |
| 279 | } |
| 280 | |
| 281 | if c.traceProvider != nil { |
| 282 | if err := c.traceProvider.Shutdown(ctx); err != nil { |
| 283 | log(ctx).Warnf("unable to shutdown trace provicer: %v", err) |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | if c.saveMetrics { |
| 288 | if metricsDir, err := mkSubdirectories(c.outputDirectory, c.outputSubdirectoryName); err != nil { |
| 289 | log(ctx).Warnf("unable to create metrics output directory '%s': %v", metricsDir, err) |
| 290 | } else { |
| 291 | if err := prometheus.WriteToTextfile(filepath.Join(metricsDir, "kopia-metrics.prom"), prometheus.DefaultGatherer); err != nil { |
| 292 | log(ctx).Warnf("unable to write metrics to file: %v", err) |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | func (c *observabilityFlags) pushPeriodically(ctx context.Context, p *push.Pusher) { |
| 299 | defer c.pusherWG.Done() |
no test coverage detected