Skip to content

Commit

Permalink
Merge pull request #29 from Chia-Network/optional-httpclient
Browse files Browse the repository at this point in the history
Optional httpclient
  • Loading branch information
cmmarslender authored Apr 19, 2022
2 parents 0a372a2 + 0e9187d commit 3fa77d0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
5 changes: 5 additions & 0 deletions internal/metrics/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 3 additions & 1 deletion internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3fa77d0

Please sign in to comment.