From c345286fb4f7fbed93c4eefd8fcdcd73ee0268f2 Mon Sep 17 00:00:00 2001 From: Robin Moser Date: Wed, 27 Jul 2022 18:16:19 +0200 Subject: [PATCH 1/2] allow configuration of the request timeout --- cmd/speedtest_exporter/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/speedtest_exporter/main.go b/cmd/speedtest_exporter/main.go index 81ff003..2872212 100644 --- a/cmd/speedtest_exporter/main.go +++ b/cmd/speedtest_exporter/main.go @@ -20,6 +20,7 @@ func main() { port := flag.String("port", "9090", "listening port to expose metrics on") serverID := flag.Int("server_id", -1, "Speedtest.net server ID to run test against, -1 will pick the closest server to your location") serverFallback := flag.Bool("server_fallback", false, "If the server_id given is not available, should we fallback to closest available server") + requestTimeout := flag.Int("timeout", 60, "request timeout for the execution of the speedtest") flag.Parse() exporter, err := exporter.New(*serverID, *serverFallback) @@ -58,7 +59,9 @@ func main() { http.Handle(metricsPath, promhttp.HandlerFor(r, promhttp.HandlerOpts{ MaxRequestsInFlight: 1, - Timeout: 60 * time.Second, + Timeout: time.Duration(*requestTimeout) * time.Second, })) + + log.Info("starting listener on port: " + *port) log.Fatal(http.ListenAndServe(":"+*port, nil)) } From b6ec778cbc44c09ce4276a42ea7ef6d31e0532e7 Mon Sep 17 00:00:00 2001 From: Robin Moser Date: Wed, 27 Jul 2022 18:58:16 +0200 Subject: [PATCH 2/2] Update the README --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a692fca..1ef48cb 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,15 @@ A [Speedtest](https://www.speedtest.net) exporter for Prometheus. ```bash $ ./speedtest_exporter --help -Usage of speedtest_exporter +Usage of speedtest_exporter: -port string listening port to expose metrics on (default "9090") -server_fallback - If the serverID given is not available, should we fallback to closest available server + If the server_id given is not available, should we fallback to closest available server -server_id int Speedtest.net server ID to run test against, -1 will pick the closest server to your location (default -1) + -timeout int + request timeout for the execution of the speedtest (default 60) ```