remote_fx: refactor collector (#1738)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2024-11-15 19:34:00 +01:00
committed by GitHub
parent a4ec0a96f1
commit 78bd720e88
32 changed files with 278 additions and 204 deletions

View File

@@ -101,14 +101,9 @@ func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
// Collect sends the metric values for each metric
// to the provided prometheus Metric channel.
func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
logger = logger.With(slog.String("collector", Name))
func (c *Collector) Collect(_ *types.ScrapeContext, _ *slog.Logger, ch chan<- prometheus.Metric) error {
if err := c.collect(ch); err != nil {
logger.Error("failed collecting thermalzone metrics",
slog.Any("err", err),
)
return err
return fmt.Errorf("failed collecting thermalzone metrics: %w", err)
}
return nil