collector: preserve failures in joined collection errors (#2574)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2026-10-09 08:22:26 +02:00
committed by GitHub
parent 8fe217e335
commit ee4c8ea0fe
4 changed files with 132 additions and 5 deletions
+14 -2
View File
@@ -337,7 +337,13 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric, _ time.Duration) error
func (c *Collector) collectKey(ch chan<- prometheus.Metric, key Key) error {
rk, err := winregistry.OpenKey(key.hive, key.subPath, winregistry.QUERY_VALUE)
if err != nil {
return fmt.Errorf("failed to open registry key %s: %w", key.label, errors.Join(err, types.ErrNoData))
// Child failures are reported by key_success and classified as no-data warnings here.
return fmt.Errorf(
"failed to open registry key %s: %s: %w",
key.label,
err.Error(),
types.ErrNoData,
)
}
defer func() {
@@ -349,7 +355,13 @@ func (c *Collector) collectKey(ch chan<- prometheus.Metric, key Key) error {
for _, value := range key.Values {
val, _, err := rk.GetIntegerValue(value.Name)
if err != nil {
errs = append(errs, fmt.Errorf("failed to read value %q of registry key %s: %w", value.Name, key.label, errors.Join(err, types.ErrNoData)))
errs = append(errs, fmt.Errorf(
"failed to read value %q of registry key %s: %s: %w",
value.Name,
key.label,
err.Error(),
types.ErrNoData,
))
continue
}
+6 -1
View File
@@ -451,7 +451,12 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric, maxScrapeDuration time.
if err != nil {
// A failing query is reported via query_success. Like the registry
// collector, it does not fail the whole collector.
errs = append(errs, fmt.Errorf("failed to collect query %s: %w", query.Name, errors.Join(err, types.ErrNoData)))
errs = append(errs, fmt.Errorf(
"failed to collect query %s: %s: %w",
query.Name,
err.Error(),
types.ErrNoData,
))
success = 0.0
c.logger.Warn("wmi query failed",