1
0
Fork 0

improve logging

This commit is contained in:
Massaki Archambault 2021-10-03 17:06:16 -04:00
parent 7dc5c2c5fb
commit 53c3a629c5
2 changed files with 13 additions and 13 deletions

View File

@ -2,7 +2,6 @@ package main
import ( import (
"flag" "flag"
"fmt"
"log" "log"
"net/http" "net/http"
"os" "os"
@ -345,7 +344,7 @@ func (e *Exporter) collectOracleMetrics(wg *sync.WaitGroup, ch chan<- prometheus
currentOraclePrice, err := heliumapi.GetCurrentOraclePrice() currentOraclePrice, err := heliumapi.GetCurrentOraclePrice()
if err != nil { if err != nil {
fmt.Println(err) log.Println(err)
return return
} }
@ -360,7 +359,7 @@ func (e *Exporter) collectStatsMetrics(wg *sync.WaitGroup, ch chan<- prometheus.
blockchainStats, err := heliumapi.GetBlockchainStats() blockchainStats, err := heliumapi.GetBlockchainStats()
if err != nil { if err != nil {
fmt.Println(err) log.Println(err)
return return
} }
@ -402,7 +401,7 @@ func (e *Exporter) collectAccountMetrics(wg *sync.WaitGroup, ch chan<- prometheu
accountForAddress, err := heliumapi.GetAccountForAddress(account.Address) accountForAddress, err := heliumapi.GetAccountForAddress(account.Address)
if err != nil { if err != nil {
fmt.Println(err) log.Println(err)
return return
} }
@ -418,7 +417,7 @@ func (e *Exporter) collectAccountActivityMetrics(wg *sync.WaitGroup, ch chan<- p
accountActivityForAddress, err := heliumapi.GetActivityCountsForAccount(account.Address) accountActivityForAddress, err := heliumapi.GetActivityCountsForAccount(account.Address)
if err != nil { if err != nil {
fmt.Println(err) log.Println(err)
return return
} }
@ -436,7 +435,7 @@ func (e *Exporter) collectAccountRewardsTotalMetrics(wg *sync.WaitGroup, ch chan
accountRewardTotalsForAddress, err := heliumapi.GetRewardTotalsForAccount(account.Address, &e.StartTime, nil) accountRewardTotalsForAddress, err := heliumapi.GetRewardTotalsForAccount(account.Address, &e.StartTime, nil)
if err != nil { if err != nil {
fmt.Println(err) log.Println(err)
return return
} }
@ -458,7 +457,7 @@ func (e *Exporter) collectAccountTransactionsMetrics(wg *sync.WaitGroup, ch chan
now := time.Now() now := time.Now()
activities, err := heliumapi.GetActivityForAccount(account.Address, []string{}, &account.Tx.LastUpdate, &now) activities, err := heliumapi.GetActivityForAccount(account.Address, []string{}, &account.Tx.LastUpdate, &now)
if err != nil { if err != nil {
fmt.Println(err) log.Println(err)
return return
} }
@ -538,7 +537,7 @@ func (e *Exporter) collectHotspotMetrics(wg *sync.WaitGroup, ch chan<- prometheu
hotspotsForAddress, err := heliumapi.GetHotspotsForAccount(account.Address) hotspotsForAddress, err := heliumapi.GetHotspotsForAccount(account.Address)
if err != nil { if err != nil {
fmt.Println(err) log.Println(err)
return return
} }
@ -581,7 +580,7 @@ func (e *Exporter) collectHotspotActivityMetrics(wg *sync.WaitGroup, ch chan<- p
hotspotActivityForAddress, err := heliumapi.GetHotspotActivityCounts(hotspotData.Address) hotspotActivityForAddress, err := heliumapi.GetHotspotActivityCounts(hotspotData.Address)
if err != nil { if err != nil {
fmt.Println(err) log.Println(err)
return return
} }
@ -599,7 +598,7 @@ func (e *Exporter) collectHotspotRewardsMetrics(wg *sync.WaitGroup, ch chan<- pr
hotspotRewardTotalsForAddress, err := heliumapi.GetRewardsTotalForHotspot(hotspotData.Address, &e.StartTime, nil) hotspotRewardTotalsForAddress, err := heliumapi.GetRewardsTotalForHotspot(hotspotData.Address, &e.StartTime, nil)
if err != nil { if err != nil {
fmt.Println(err) log.Println(err)
return return
} }
@ -641,9 +640,9 @@ func main() {
}) })
http.Handle(*fMetricsPath, promhttp.HandlerFor(r, promhttp.HandlerOpts{})) http.Handle(*fMetricsPath, promhttp.HandlerFor(r, promhttp.HandlerOpts{}))
fmt.Printf("listening on %v\n", serverAddr) log.Printf("listening on %v\n", serverAddr)
if err = http.ListenAndServe(serverAddr, nil); err != nil { if err = http.ListenAndServe(serverAddr, nil); err != nil {
fmt.Println(err) log.Println(err)
os.Exit(1) os.Exit(1)
} }
} }

View File

@ -3,6 +3,7 @@ package activity
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"log"
) )
type ActivityResp struct { type ActivityResp struct {
@ -88,7 +89,7 @@ func NewActivities(resp ActivityResp) (*Activities, error) {
} }
activities.UnstakeValidatorV1 = append(activities.UnstakeValidatorV1, unstakeValidatorV1) activities.UnstakeValidatorV1 = append(activities.UnstakeValidatorV1, unstakeValidatorV1)
default: default:
fmt.Printf("ignoring unimplemented activy type: %v", activityType.Type) log.Printf("ignoring unimplemented activy type: %v", activityType.Type)
} }
} }