mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-04 01:26:37 +00:00
@@ -72,7 +72,7 @@ func TestRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
ctx, cancel := context.WithCancel(t.Context())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
if tc.config != "" {
|
if tc.config != "" {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package textfile_test
|
package textfile_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
@@ -44,7 +45,7 @@ func TestMultipleDirectories(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
collectors := collector.New(map[string]collector.Collector{textfile.Name: textFileCollector})
|
collectors := collector.New(map[string]collector.Collector{textfile.Name: textFileCollector})
|
||||||
require.NoError(t, collectors.Build(t.Context(), logger))
|
require.NoError(t, collectors.Build(context.Background(), logger))
|
||||||
|
|
||||||
metrics := make(chan prometheus.Metric)
|
metrics := make(chan prometheus.Metric)
|
||||||
got := ""
|
got := ""
|
||||||
@@ -81,7 +82,7 @@ func TestDuplicateFileName(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
collectors := collector.New(map[string]collector.Collector{textfile.Name: textFileCollector})
|
collectors := collector.New(map[string]collector.Collector{textfile.Name: textFileCollector})
|
||||||
require.NoError(t, collectors.Build(t.Context(), logger))
|
require.NoError(t, collectors.Build(context.Background(), logger))
|
||||||
|
|
||||||
metrics := make(chan prometheus.Metric)
|
metrics := make(chan prometheus.Metric)
|
||||||
got := ""
|
got := ""
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -91,6 +92,7 @@ func NewConfigFileResolver(file string) (*Resolver, error) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if strings.HasPrefix(file, "http://") || strings.HasPrefix(file, "https://") {
|
if strings.HasPrefix(file, "http://") || strings.HasPrefix(file, "https://") {
|
||||||
|
//nolint:sloglint // we do not have an logger yet
|
||||||
slog.Warn("Loading configuration file from URL is deprecated and will be removed in 0.31.0. Use a local file instead.")
|
slog.Warn("Loading configuration file from URL is deprecated and will be removed in 0.31.0. Use a local file instead.")
|
||||||
|
|
||||||
fileBytes, err = readFromURL(file)
|
fileBytes, err = readFromURL(file)
|
||||||
@@ -142,7 +144,7 @@ func readFromURL(file string) ([]byte, error) {
|
|||||||
|
|
||||||
client := &http.Client{Transport: tr}
|
client := &http.Client{Transport: tr}
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodGet, file, nil)
|
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, file, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create HTTP request: %w", err)
|
return nil, fmt.Errorf("failed to create HTTP request: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package testutils
|
package testutils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
@@ -47,7 +48,7 @@ func FuncBenchmarkCollector[C collector.Collector](b *testing.B, name string, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
collectors := collector.New(map[string]collector.Collector{name: c})
|
collectors := collector.New(map[string]collector.Collector{name: c})
|
||||||
require.NoError(b, collectors.Build(b.Context(), logger))
|
require.NoError(b, collectors.Build(context.Background(), logger))
|
||||||
|
|
||||||
metrics := make(chan prometheus.Metric)
|
metrics := make(chan prometheus.Metric)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user