mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-08 05:56:37 +00:00
chore(deps): update dependency golangci/golangci-lint to v2.6.0 (#2246)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@@ -91,5 +91,5 @@ jobs:
|
|||||||
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
|
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
|
||||||
with:
|
with:
|
||||||
# renovate: github=golangci/golangci-lint
|
# renovate: github=golangci/golangci-lint
|
||||||
version: v2.5.0
|
version: v2.6.0
|
||||||
args: "--max-same-issues=0"
|
args: "--max-same-issues=0"
|
||||||
|
|||||||
@@ -775,6 +775,7 @@ func (c *Collector) workerBitlocker(ctx context.Context, initErrCh chan<- error)
|
|||||||
// Otherwise, attempting to initialize and run parallel queries across
|
// Otherwise, attempting to initialize and run parallel queries across
|
||||||
// goroutines will result in protected memory errors.
|
// goroutines will result in protected memory errors.
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
|
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {
|
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"maps"
|
||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"slices"
|
"slices"
|
||||||
@@ -184,7 +185,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
|||||||
|
|
||||||
return reflect.StructField{
|
return reflect.StructField{
|
||||||
Name: strings.ToUpper(sanitizeMetricName(name)),
|
Name: strings.ToUpper(sanitizeMetricName(name)),
|
||||||
Type: reflect.TypeOf(float64(0)),
|
Type: reflect.TypeFor[float64](),
|
||||||
Tag: reflect.StructTag(fmt.Sprintf(`perfdata:"%s"`, name)),
|
Tag: reflect.StructTag(fmt.Sprintf(`perfdata:"%s"`, name)),
|
||||||
}, nil
|
}, nil
|
||||||
}(counter.Name)
|
}(counter.Name)
|
||||||
@@ -200,13 +201,13 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
|||||||
if object.Instances != nil {
|
if object.Instances != nil {
|
||||||
fields = append(fields, reflect.StructField{
|
fields = append(fields, reflect.StructField{
|
||||||
Name: "Name",
|
Name: "Name",
|
||||||
Type: reflect.TypeOf(""),
|
Type: reflect.TypeFor[string](),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fields = append(fields, reflect.StructField{
|
fields = append(fields, reflect.StructField{
|
||||||
Name: "MetricType",
|
Name: "MetricType",
|
||||||
Type: reflect.TypeOf(prometheus.ValueType(0)),
|
Type: reflect.TypeFor[prometheus.ValueType](),
|
||||||
})
|
})
|
||||||
|
|
||||||
valueType := reflect.StructOf(fields)
|
valueType := reflect.StructOf(fields)
|
||||||
@@ -321,7 +322,7 @@ func (c *Collector) collectObject(ch chan<- prometheus.Metric, perfDataObject Ob
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if field.Kind() != reflect.TypeOf(prometheus.ValueType(0)).Kind() {
|
if field.Kind() != reflect.TypeFor[prometheus.ValueType]().Kind() {
|
||||||
errs = append(errs, fmt.Errorf("failed to cast MetricType for %s to prometheus.ValueType", counter.Name))
|
errs = append(errs, fmt.Errorf("failed to cast MetricType for %s to prometheus.ValueType", counter.Name))
|
||||||
|
|
||||||
continue
|
continue
|
||||||
@@ -351,9 +352,7 @@ func (c *Collector) collectObject(ch chan<- prometheus.Metric, perfDataObject Ob
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value := range counter.Labels {
|
maps.Copy(labels, counter.Labels)
|
||||||
labels[key] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
switch counter.Type {
|
switch counter.Type {
|
||||||
case "counter":
|
case "counter":
|
||||||
|
|||||||
@@ -248,6 +248,7 @@ func getScheduledTasks() (ScheduledTasks, error) {
|
|||||||
// Otherwise, attempting to initialize and run parallel queries across
|
// Otherwise, attempting to initialize and run parallel queries across
|
||||||
// goroutines will result in protected memory errors.
|
// goroutines will result in protected memory errors.
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
|
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {
|
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {
|
||||||
@@ -256,6 +257,7 @@ func getScheduledTasks() (ScheduledTasks, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defer ole.CoUninitialize()
|
defer ole.CoUninitialize()
|
||||||
|
|
||||||
schedClassID, err := ole.ClassIDFrom(SCHEDULED_TASK_PROGRAM_ID)
|
schedClassID, err := ole.ClassIDFrom(SCHEDULED_TASK_PROGRAM_ID)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -183,17 +184,7 @@ func (c *Collector) convertMetricFamily(logger *slog.Logger, metricFamily *dto.M
|
|||||||
}
|
}
|
||||||
|
|
||||||
for k := range allLabelNames {
|
for k := range allLabelNames {
|
||||||
present := false
|
if !slices.Contains(names, k) {
|
||||||
|
|
||||||
for _, name := range names {
|
|
||||||
if k == name {
|
|
||||||
present = true
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !present {
|
|
||||||
names = append(names, k)
|
names = append(names, k)
|
||||||
values = append(values, "")
|
values = append(values, "")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ func TestMultipleDirectories(t *testing.T) {
|
|||||||
err := val.Write(&metric)
|
err := val.Write(&metric)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
//nolint:modernize,perfsprint
|
||||||
got += metric.String()
|
got += metric.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +103,7 @@ func TestDuplicateFileName(t *testing.T) {
|
|||||||
err := val.Write(&metric)
|
err := val.Write(&metric)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
//nolint:perfsprint
|
||||||
got += metric.String()
|
got += metric.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -176,6 +176,7 @@ func (c *Collector) scheduleUpdateStatus(ctx context.Context, logger *slog.Logge
|
|||||||
// Otherwise, attempting to initialize and run parallel queries across
|
// Otherwise, attempting to initialize and run parallel queries across
|
||||||
// goroutines will result in protected memory errors.
|
// goroutines will result in protected memory errors.
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
|
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {
|
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {
|
||||||
|
|||||||
@@ -96,12 +96,12 @@ func Parse(app *kingpin.Application, args []string) error {
|
|||||||
// ParseConfigFile manually parses the configuration file from the command line arguments.
|
// ParseConfigFile manually parses the configuration file from the command line arguments.
|
||||||
func ParseConfigFile(args []string) string {
|
func ParseConfigFile(args []string) string {
|
||||||
for i, cliFlag := range args {
|
for i, cliFlag := range args {
|
||||||
if strings.HasPrefix(cliFlag, "--config.file=") {
|
if configFile, ok := strings.CutPrefix(cliFlag, "--config.file="); ok {
|
||||||
return strings.TrimPrefix(cliFlag, "--config.file=")
|
return configFile
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(cliFlag, "-config.file=") {
|
if configFile, ok := strings.CutPrefix(cliFlag, "-config.file="); ok {
|
||||||
return strings.TrimPrefix(cliFlag, "-config.file=")
|
return configFile
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasSuffix(cliFlag, "-config.file") {
|
if strings.HasSuffix(cliFlag, "-config.file") {
|
||||||
@@ -148,7 +148,7 @@ func NewConfigFileResolver(filePath string) (*Resolver, error) {
|
|||||||
return nil, fmt.Errorf("failed to rewind file: %w", err)
|
return nil, fmt.Errorf("failed to rewind file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var rawValues map[string]interface{}
|
var rawValues map[string]any
|
||||||
|
|
||||||
decoder = yaml.NewDecoder(file)
|
decoder = yaml.NewDecoder(file)
|
||||||
if err = decoder.Decode(&rawValues); err != nil {
|
if err = decoder.Decode(&rawValues); err != nil {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func TestConfigFlattening(t *testing.T) {
|
|||||||
log:
|
log:
|
||||||
level: debug`)
|
level: debug`)
|
||||||
|
|
||||||
var data map[string]interface{}
|
var data map[string]any
|
||||||
|
|
||||||
err := yaml.Unmarshal(goodYamlConfig, &data)
|
err := yaml.Unmarshal(goodYamlConfig, &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ type Properties struct {
|
|||||||
type ProcessDetails struct {
|
type ProcessDetails struct {
|
||||||
ProcessId int32 `json:"ProcessId,omitempty"`
|
ProcessId int32 `json:"ProcessId,omitempty"`
|
||||||
ImageName string `json:"ImageName,omitempty"`
|
ImageName string `json:"ImageName,omitempty"`
|
||||||
CreateTimestamp time.Time `json:"CreateTimestamp,omitempty"`
|
CreateTimestamp time.Time `json:"CreateTimestamp"`
|
||||||
UserTime100ns int32 `json:"UserTime100ns,omitempty"`
|
UserTime100ns int32 `json:"UserTime100ns,omitempty"`
|
||||||
KernelTime100ns int32 `json:"KernelTime100ns,omitempty"`
|
KernelTime100ns int32 `json:"KernelTime100ns,omitempty"`
|
||||||
MemoryCommitBytes int32 `json:"MemoryCommitBytes,omitempty"`
|
MemoryCommitBytes int32 `json:"MemoryCommitBytes,omitempty"`
|
||||||
@@ -55,8 +55,8 @@ type ProcessDetails struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Statistics struct {
|
type Statistics struct {
|
||||||
Timestamp time.Time `json:"Timestamp,omitempty"`
|
Timestamp time.Time `json:"Timestamp"`
|
||||||
ContainerStartTime time.Time `json:"ContainerStartTime,omitempty"`
|
ContainerStartTime time.Time `json:"ContainerStartTime"`
|
||||||
Uptime100ns uint64 `json:"Uptime100ns,omitempty"`
|
Uptime100ns uint64 `json:"Uptime100ns,omitempty"`
|
||||||
Processor *ProcessorStats `json:"Processor,omitempty"`
|
Processor *ProcessorStats `json:"Processor,omitempty"`
|
||||||
Memory *MemoryStats `json:"Memory,omitempty"`
|
Memory *MemoryStats `json:"Memory,omitempty"`
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ func (s *ScheduleService) Connect() error {
|
|||||||
// Otherwise, attempting to initialize and run parallel queries across
|
// Otherwise, attempting to initialize and run parallel queries across
|
||||||
// goroutines will result in protected memory errors.
|
// goroutines will result in protected memory errors.
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
|
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {
|
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ func NewCollectorWithReflection(logger *slog.Logger, resultType CounterType, obj
|
|||||||
}
|
}
|
||||||
|
|
||||||
if f, ok := valueType.FieldByName("MetricType"); ok {
|
if f, ok := valueType.FieldByName("MetricType"); ok {
|
||||||
if f.Type.Kind() == reflect.TypeOf(prometheus.ValueType(0)).Kind() {
|
if f.Type.Kind() == reflect.TypeFor[prometheus.ValueType]().Kind() {
|
||||||
collector.metricsTypeIndexValue = f.Index[0]
|
collector.metricsTypeIndexValue = f.Index[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,9 +53,7 @@ func NewCollector[T any](object string, _ []string) (*Collector, error) {
|
|||||||
counters: make(map[string]Counter),
|
counters: make(map[string]Counter),
|
||||||
}
|
}
|
||||||
|
|
||||||
var values [0]T
|
valueType := reflect.TypeFor[T]().Elem()
|
||||||
|
|
||||||
valueType := reflect.TypeOf(values).Elem()
|
|
||||||
|
|
||||||
if f, ok := valueType.FieldByName("Name"); ok {
|
if f, ok := valueType.FieldByName("Name"); ok {
|
||||||
if f.Type.Kind() == reflect.String {
|
if f.Type.Kind() == reflect.String {
|
||||||
@@ -81,9 +79,7 @@ func NewCollector[T any](object string, _ []string) (*Collector, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasSuffix(counterName, ",secondvalue") {
|
if counterName, ok = strings.CutSuffix(counterName, ",secondvalue"); ok {
|
||||||
counterName = strings.TrimSuffix(counterName, ",secondvalue")
|
|
||||||
|
|
||||||
counter.FieldIndexSecondValue = f.Index[0]
|
counter.FieldIndexSecondValue = f.Index[0]
|
||||||
} else {
|
} else {
|
||||||
counter.FieldIndexValue = f.Index[0]
|
counter.FieldIndexValue = f.Index[0]
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func FuncBenchmarkCollector[C collector.Collector](b *testing.B, name string, co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCollector[C collector.Collector, V interface{}](t *testing.T, fn func(*V) C, conf *V) {
|
func TestCollector[C collector.Collector, V any](t *testing.T, fn func(*V) C, conf *V) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -89,15 +89,11 @@ func TestCollector[C collector.Collector, V interface{}](t *testing.T, fn func(*
|
|||||||
})
|
})
|
||||||
|
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
|
|
||||||
for metric := range ch {
|
for metric := range ch {
|
||||||
metrics = append(metrics, metric)
|
metrics = append(metrics, metric)
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
|
|
||||||
err = c.Build(logger, miSession)
|
err = c.Build(logger, miSession)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user