diff --git a/exporter/device.go b/exporter/device.go index 9b30a48..c28b349 100644 --- a/exporter/device.go +++ b/exporter/device.go @@ -16,7 +16,7 @@ type Device struct { } func (e *Exporter) fetchDeviceData(ctx context.Context) ([]Device, error) { - ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + ctx, cancel := context.WithTimeout(ctx, 30*time.Second) defer cancel() params := &devices.GetDevicesParams{ diff --git a/exporter/device_test.go b/exporter/device_test.go index 76f2892..84e411e 100644 --- a/exporter/device_test.go +++ b/exporter/device_test.go @@ -43,7 +43,7 @@ func TestDevice_PingMetrics_connected(t *testing.T) { actual := subject.PingMetrics() if actual == nil { - t.Error("expected PingMetrics() to return somthing, got nil") + t.Fatal("expected PingMetrics() to return somthing, got nil") } comparePingMetrics(t, metricExpectation{ @@ -68,7 +68,7 @@ func TestDevice_PingMetrics_missingPackets(t *testing.T) { actual := subject.PingMetrics() if actual == nil { - t.Error("expected PingMetrics() to return somthing, got nil") + t.Fatal("expected PingMetrics() to return somthing, got nil") } comparePingMetrics(t, metricExpectation{ diff --git a/internal/handler/handler.go b/internal/handler/handler.go index 6515f59..9c72c52 100644 --- a/internal/handler/handler.go +++ b/internal/handler/handler.go @@ -8,6 +8,7 @@ import ( "github.com/ffddorf/unms-exporter/exporter" "github.com/ffddorf/unms-exporter/internal/cli/config" "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/collectors" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/sirupsen/logrus" ) @@ -21,8 +22,8 @@ type handler struct { func New(logger logrus.FieldLogger, cfg *config.Config) (http.Handler, error) { reg := prometheus.NewPedanticRegistry() reg.MustRegister( - prometheus.NewBuildInfoCollector(), - prometheus.NewGoCollector(), + collectors.NewBuildInfoCollector(), + collectors.NewGoCollector(), ) exporters := make(map[string]*exporter.Exporter)