From 462025f5fa31821b79b399bf4c56c2d21e235f56 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Thu, 13 Oct 2022 14:23:52 -0400 Subject: [PATCH] metrics agent infrastructure --- controller/controller.go | 5 +++++ controller/metrics.go | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/controller/controller.go b/controller/controller.go index dad85dd4..14676bea 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -11,6 +11,7 @@ import ( ) var str *store.Store +var mtr *metricsAgent const version = "v0.2.0" @@ -43,6 +44,9 @@ func Run(cfg *Config) error { return errors.Wrap(err, "error opening store") } + mtr = newMetricsAgent(cfg.MetricsConfig) + go mtr.run() + server := rest_server_zrok.NewServer(api) defer func() { _ = server.Shutdown() }() server.Host = cfg.Endpoint.Host @@ -51,5 +55,6 @@ func Run(cfg *Config) error { if err := server.Serve(); err != nil { return errors.Wrap(err, "api server error") } + return nil } diff --git a/controller/metrics.go b/controller/metrics.go index 319ac3d2..946fff2b 100644 --- a/controller/metrics.go +++ b/controller/metrics.go @@ -1,5 +1,10 @@ package controller +import ( + "github.com/sirupsen/logrus" + "time" +) + type MetricsConfig struct { Influx *InfluxConfig } @@ -10,3 +15,20 @@ type InfluxConfig struct { Org string Token string } + +type metricsAgent struct { + cfg *MetricsConfig +} + +func newMetricsAgent(cfg *MetricsConfig) *metricsAgent { + return &metricsAgent{cfg: cfg} +} + +func (mtr *metricsAgent) run() { + logrus.Info("starting") + defer logrus.Info("exiting") + + for { + time.Sleep(24 * time.Hour) + } +}