From 1652cea18592474be68ad28bee2acdfccc84fc21 Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 19 Apr 2022 11:48:31 -0500 Subject: [PATCH 1/2] Make the http client optional, since it is only used for additional data, not the core metrics --- internal/metrics/crawler.go | 5 +++++ internal/metrics/metrics.go | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/metrics/crawler.go b/internal/metrics/crawler.go index b4de3dc..7396143 100644 --- a/internal/metrics/crawler.go +++ b/internal/metrics/crawler.go @@ -125,6 +125,11 @@ func (s *CrawlerServiceMetrics) StartIPCountryMapping(limit uint) { return } + if s.metrics.httpClient == nil { + log.Println("httpClient is nil, skipping IP mapping") + return + } + log.Println("Requesting IP addresses from the past 5 days for country mapping...") ipsAfterTimestamp, _, err := s.metrics.httpClient.CrawlerService.GetIPsAfterTimestamp(&rpc.GetIPsAfterTimestampOptions{ diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index ed10ea4..bf72379 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go @@ -73,7 +73,9 @@ func NewMetrics(port uint16) (*Metrics, error) { metrics.httpClient, err = rpc.NewClient(rpc.ConnectionModeHTTP) if err != nil { - return nil, err + // For now, http client is optional + // Sometimes this fails with outdated config.yaml files that don't have the crawler/seeder section present + log.Printf("Error creating http client: %s\n", err.Error()) } // Register each service's metrics From 0e9187d593fcb1fd2562a102ba2d3b8f01b2545f Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 19 Apr 2022 11:52:51 -0500 Subject: [PATCH 2/2] v0.0.2 of go chia libs --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 69dd00d..c0e8bb6 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/chia-network/chia-exporter go 1.17 require ( - github.com/chia-network/go-chia-libs v0.0.0-20220315010935-f83139bbcc00 + github.com/chia-network/go-chia-libs v0.0.2 github.com/oschwald/maxminddb-golang v1.8.0 github.com/prometheus/client_golang v1.12.0 github.com/spf13/cobra v1.3.0 diff --git a/go.sum b/go.sum index 5c02a66..da7c6db 100644 --- a/go.sum +++ b/go.sum @@ -73,8 +73,8 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chia-network/go-chia-libs v0.0.0-20220315010935-f83139bbcc00 h1:C8XRe0ptpS2m64pCe+mBFYilWWrbj2zAT2T8YP5LLs4= -github.com/chia-network/go-chia-libs v0.0.0-20220315010935-f83139bbcc00/go.mod h1:h1y8enwmbHVylzRDd5jA9C7RZMXX82pV8/rviB7L4V8= +github.com/chia-network/go-chia-libs v0.0.2 h1:ZedKuk7n80V+cVmuWnyJrBEtUf41y6WlBE/Tpq+FQ5A= +github.com/chia-network/go-chia-libs v0.0.2/go.mod h1:h1y8enwmbHVylzRDd5jA9C7RZMXX82pV8/rviB7L4V8= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=