(ctx context.Context)
| 63 | } |
| 64 | |
| 65 | func (f *Flusher) running(ctx context.Context) error { |
| 66 | ing, err := ingester.NewForFlusher(f.ingesterConfig, f.limits, f.registerer, f.logger) |
| 67 | if err != nil { |
| 68 | return errors.Wrap(err, "create ingester") |
| 69 | } |
| 70 | |
| 71 | if err := services.StartAndAwaitRunning(ctx, ing); err != nil { |
| 72 | return errors.Wrap(err, "start and await running ingester") |
| 73 | } |
| 74 | |
| 75 | ing.Flush() |
| 76 | |
| 77 | // Sleeping to give a chance to Prometheus |
| 78 | // to collect the metrics. |
| 79 | level.Info(f.logger).Log("msg", "sleeping to give chance for collection of metrics", "duration", postFlushSleepTime.String()) |
| 80 | time.Sleep(postFlushSleepTime) |
| 81 | |
| 82 | if err := services.StopAndAwaitTerminated(ctx, ing); err != nil { |
| 83 | return errors.Wrap(err, "stop and await terminated ingester") |
| 84 | } |
| 85 | |
| 86 | if f.cfg.ExitAfterFlush { |
| 87 | return modules.ErrStopProcess |
| 88 | } |
| 89 | |
| 90 | // Return normally -- this keep Cortex running. |
| 91 | return nil |
| 92 | } |
nothing calls this directly
no test coverage detected