blob: 78c62d61c2901fdd18d1efff639f3f9a02f20c05 [file] [log] [blame]
Serge Bazanski54e212a2023-06-14 13:45:11 +02001package roleserve
2
3import (
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.
15type workerMetrics struct {
16 curatorConnection *memory.Value[*curatorConnection]
17}
18
19func (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}