mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-27 15:16:35 +00:00
feat: Tolerate collector failures (#1769)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -27,7 +27,10 @@ import (
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
// We have to registry a global callback function, since the amount of callbacks is limited.
|
||||
// operationUnmarshalCallbacksInstanceResult registers a global callback function.
|
||||
// The amount of system callbacks is limited to 2000.
|
||||
//
|
||||
//nolint:gochecknoglobals
|
||||
var operationUnmarshalCallbacksInstanceResult = sync.OnceValue[uintptr](func() uintptr {
|
||||
// Workaround for a deadlock issue in go.
|
||||
// Ref: https://github.com/golang/go/issues/55015
|
||||
@@ -135,7 +138,7 @@ func (o *OperationUnmarshalCallbacks) InstanceResult(
|
||||
|
||||
element, err := instance.GetElement(miTag)
|
||||
if err != nil {
|
||||
o.errCh <- fmt.Errorf("failed to get element: %w", err)
|
||||
o.errCh <- fmt.Errorf("failed to get element %s: %w", miTag, err)
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -149,9 +152,8 @@ func (o *OperationUnmarshalCallbacks) InstanceResult(
|
||||
field.SetInt(int64(element.value))
|
||||
case ValueTypeSTRING:
|
||||
if element.value == 0 {
|
||||
o.errCh <- fmt.Errorf("%s: invalid pointer: value is nil", miTag)
|
||||
|
||||
return 0
|
||||
// value is null
|
||||
continue
|
||||
}
|
||||
|
||||
// Convert the UTF-16 string to a Go string
|
||||
|
||||
Reference in New Issue
Block a user