Skip to content

Commit

Permalink
feat: Tolerate collector failures
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Nov 25, 2024
1 parent f3cdb48 commit f46e8f4
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/collector/license/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

const Name = "license"

//nolint:gochecknoglobals
var labelMap = map[slc.SL_GENUINE_STATE]string{
slc.SL_GEN_STATE_IS_GENUINE: "genuine",
slc.SL_GEN_STATE_INVALID_LICENSE: "invalid_license",
Expand Down
2 changes: 2 additions & 0 deletions internal/collector/net/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error {
return nil
}

//nolint:gochecknoglobals

Check failure on line 396 in internal/collector/net/net.go

View workflow job for this annotation

GitHub Actions / lint

directive `//nolint:gochecknoglobals` is unused for linter "gochecknoglobals" (nolintlint)

var addressFamily = map[uint16]string{

Check failure on line 398 in internal/collector/net/net.go

View workflow job for this annotation

GitHub Actions / lint

addressFamily is a global variable (gochecknoglobals)
windows.AF_INET: "ipv4",
windows.AF_INET6: "ipv6",
Expand Down
1 change: 1 addition & 0 deletions internal/collector/scheduled_task/scheduled_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const (
SCHED_S_TASK_HAS_NOT_RUN TaskResult = 0x00041303
)

//nolint:gochecknoglobals
var taskStates = []string{"disabled", "queued", "ready", "running", "unknown"}

type scheduledTask struct {
Expand Down
1 change: 1 addition & 0 deletions internal/mi/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var (
DestinationOptionsUILocale = UTF16PtrFromString[*uint16]("__MI_DESTINATIONOPTIONS_UI_LOCALE")
)

//nolint:gochecknoglobals
var (
modMi = windows.NewLazySystemDLL("mi.dll")

Expand Down
2 changes: 2 additions & 0 deletions internal/mi/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
// OperationOptionsTimeout is the key for the timeout option.
//
// https://github.com/microsoft/win32metadata/blob/527806d20d83d3abd43d16cd3fa8795d8deba343/generation/WinSDK/RecompiledIdlHeaders/um/mi.h#L9240
//
//nolint:gochecknoglobals
var OperationOptionsTimeout = UTF16PtrFromString[*uint16]("__MI_OPERATIONOPTIONS_TIMEOUT")

// OperationFlags represents the flags for an operation.
Expand Down
1 change: 1 addition & 0 deletions internal/perfdata/pdh.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const (
PdhQueryPerfDataTimeout uint32 = 0xC0000BFE
)

//nolint:gochecknoglobals
var PDHErrors = map[uint32]string{
PdhCstatusValidData: "PDH_CSTATUS_VALID_DATA",
PdhCstatusNewData: "PDH_CSTATUS_NEW_DATA",
Expand Down
1 change: 1 addition & 0 deletions pkg/collector/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ type Config struct {

// ConfigDefaults Is an interface to be used by the external libraries. It holds all ConfigDefaults form all collectors
//
//nolint:gochecknoglobals
//goland:noinspection GoUnusedGlobalVariable
var ConfigDefaults = Config{
AD: ad.ConfigDefaults,
Expand Down
1 change: 1 addition & 0 deletions pkg/collector/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func NewBuilderWithFlags[C Collector](fn BuilderWithFlags[C]) BuilderWithFlags[C
}
}

//nolint:gochecknoglobals
var BuildersWithFlags = map[string]BuilderWithFlags[Collector]{
ad.Name: NewBuilderWithFlags(ad.NewWithFlags),
adcs.Name: NewBuilderWithFlags(adcs.NewWithFlags),
Expand Down

0 comments on commit f46e8f4

Please sign in to comment.