mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-07 21:46:37 +00:00
@@ -72,7 +72,7 @@ func TestRun(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()
|
||||
|
||||
if tc.config != "" {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package textfile_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
@@ -44,7 +45,7 @@ func TestMultipleDirectories(t *testing.T) {
|
||||
})
|
||||
|
||||
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)
|
||||
got := ""
|
||||
@@ -81,7 +82,7 @@ func TestDuplicateFileName(t *testing.T) {
|
||||
})
|
||||
|
||||
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)
|
||||
got := ""
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -91,6 +92,7 @@ func NewConfigFileResolver(file string) (*Resolver, error) {
|
||||
)
|
||||
|
||||
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.")
|
||||
|
||||
fileBytes, err = readFromURL(file)
|
||||
@@ -142,7 +144,7 @@ func readFromURL(file string) ([]byte, error) {
|
||||
|
||||
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 {
|
||||
return nil, fmt.Errorf("failed to create HTTP request: %w", err)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package testutils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"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})
|
||||
require.NoError(b, collectors.Build(b.Context(), logger))
|
||||
require.NoError(b, collectors.Build(context.Background(), logger))
|
||||
|
||||
metrics := make(chan prometheus.Metric)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user