Skip to content

Commit

Permalink
Merge pull request #17 from Hsn723/fix-timeout
Browse files Browse the repository at this point in the history
fix timeout on metrics collection
  • Loading branch information
Hsn723 committed Nov 28, 2023
2 parents a47f886 + 77fd11a commit 1b9866b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.1.1
3 changes: 1 addition & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net/http"
"os"
"strconv"
"time"

"github.com/hsn723/rdap-exporter/collector"
"github.com/hsn723/rdap-exporter/config"
Expand Down Expand Up @@ -45,7 +44,7 @@ func runRoot(cmd *cobra.Command, _ []string) error {
rdapExporter := collector.NewRdapExporter(*conf)
prometheus.MustRegister(rdapExporter)

ctx, cancelFunc := context.WithTimeout(cmd.Context(), time.Duration(conf.Timeout)*time.Second)
ctx, cancelFunc := context.WithCancel(cmd.Context())
defer cancelFunc()
go rdapExporter.StartMetricsCollection(ctx)

Expand Down
1 change: 1 addition & 0 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func collectRdapInfo(ctx context.Context, e *RdapExporter, domain string) {
Query: domain,
}
req = req.WithContext(ctx)
req.Timeout = time.Duration(e.config.Timeout) * time.Second
client := &rdap.Client{}
resp, err := client.Do(req)
if err != nil {
Expand Down

0 comments on commit 1b9866b

Please sign in to comment.