| Serge Bazanski | 54e212a | 2023-06-14 13:45:11 +0200 | [diff] [blame] | 1 | package roleserve |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | |
| 6 | "source.monogon.dev/metropolis/node/core/metrics" |
| 7 | "source.monogon.dev/metropolis/pkg/event/memory" |
| 8 | "source.monogon.dev/metropolis/pkg/supervisor" |
| 9 | ) |
| 10 | |
| 11 | // workerMetrics runs the Metrics Service, which runs local Prometheus collectors |
| 12 | // (themselves usually instances of existing Prometheus Exporters running as |
| 13 | // sub-processes), and a forwarding service that lets external users access them |
| 14 | // over HTTPS using the Cluster CA. |
| 15 | type workerMetrics struct { |
| 16 | curatorConnection *memory.Value[*curatorConnection] |
| 17 | } |
| 18 | |
| 19 | func (s *workerMetrics) run(ctx context.Context) error { |
| 20 | w := s.curatorConnection.Watch() |
| 21 | defer w.Close() |
| 22 | |
| 23 | supervisor.Logger(ctx).Infof("Waiting for curator connection") |
| 24 | cc, err := w.Get(ctx) |
| 25 | if err != nil { |
| 26 | return err |
| 27 | } |
| 28 | supervisor.Logger(ctx).Infof("Got curator connection, starting...") |
| 29 | |
| 30 | svc := metrics.Service{ |
| 31 | Credentials: cc.credentials, |
| 32 | } |
| 33 | return svc.Run(ctx) |
| 34 | } |