performancecounter: support yaml documents and tolerate collector errors (#1809)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2024-12-09 19:14:26 +01:00
committed by GitHub
parent a9698e27bf
commit eea5a50d5c
14 changed files with 363 additions and 129 deletions

View File

@@ -206,8 +206,9 @@ func (c *Collection) collectCollector(ch chan<- prometheus.Metric, logger *slog.
if err != nil && !errors.Is(err, perfdata.ErrNoData) && !errors.Is(err, types.ErrNoData) {
loggerFn := logger.Warn
if errors.Is(err, perfdata.ErrPerformanceCounterNotInitialized) || errors.Is(err, mi.MI_RESULT_INVALID_NAMESPACE) {
loggerFn = logger.Debug
err = fmt.Errorf("%w. Check application logs from initialization pharse for more information", err)
}
loggerFn(fmt.Sprintf("collector %s failed after %s, resulting in %d metrics", name, duration, numMetrics),