From 29d144f2e3ee7878c93a6fea23dd0936cdb198c7 Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Thu, 28 Sep 2023 09:19:43 -0500 Subject: [PATCH] Add debug to the other services --- internal/metrics/crawler.go | 8 ++++++++ internal/metrics/farmer.go | 8 ++++++++ internal/metrics/fullnode.go | 2 +- internal/metrics/harvester.go | 8 ++++++++ internal/metrics/timelord.go | 8 ++++++++ internal/metrics/wallet.go | 8 ++++++++ 6 files changed, 41 insertions(+), 1 deletion(-) diff --git a/internal/metrics/crawler.go b/internal/metrics/crawler.go index 99dfb03..cf74e2a 100644 --- a/internal/metrics/crawler.go +++ b/internal/metrics/crawler.go @@ -37,6 +37,9 @@ type CrawlerServiceMetrics struct { ipv6Nodes5Days *wrappedPrometheus.LazyGauge versionBuckets *prometheus.GaugeVec countryNodeCountBuckets *prometheus.GaugeVec + + // Debug Metric + debug *prometheus.GaugeVec } // InitMetrics sets all the metrics properties @@ -49,6 +52,9 @@ func (s *CrawlerServiceMetrics) InitMetrics() { s.versionBuckets = s.metrics.newGaugeVec(chiaServiceCrawler, "peer_version", "Number of peers for each version. Only peers the crawler was able to connect to are included here.", []string{"version"}) s.countryNodeCountBuckets = s.metrics.newGaugeVec(chiaServiceCrawler, "country_node_count", "Number of peers gossiped in the last 5 days from each country.", []string{"country", "country_display"}) + // Debug Metric + s.debug = s.metrics.newGaugeVec(chiaServiceCrawler, "debug_metrics", "random debugging metrics distinguished by labels", []string{"key"}) + err := s.initMaxmindDB() if err != nil { // Continue on maxmind error - optional/not critical functionality @@ -104,6 +110,8 @@ func (s *CrawlerServiceMetrics) ReceiveResponse(resp *types.WebsocketResponse) { fallthrough case "crawl_batch_completed": s.GetPeerCounts(resp) + case "debug": + debugHelper(resp, s.debug) } } diff --git a/internal/metrics/farmer.go b/internal/metrics/farmer.go index 3b3c4dd..f416ea3 100644 --- a/internal/metrics/farmer.go +++ b/internal/metrics/farmer.go @@ -47,6 +47,9 @@ type FarmerServiceMetrics struct { totalEligiblePlots *prometheus.CounterVec lastEligiblePlots *prometheus.GaugeVec lastLookupTime *prometheus.GaugeVec + + // Debug Metric + debug *prometheus.GaugeVec } // InitMetrics sets all the metrics properties @@ -75,6 +78,9 @@ func (s *FarmerServiceMetrics) InitMetrics() { s.totalEligiblePlots = s.metrics.newCounterVec(chiaServiceFarmer, "total_eligible_plots", "Counter of total eligible plots since the exporter started", []string{"host", "node_id"}) s.lastEligiblePlots = s.metrics.newGaugeVec(chiaServiceFarmer, "last_eligible_plots", "Number of eligible plots for the last farmer_info event", []string{"host", "node_id"}) s.lastLookupTime = s.metrics.newGaugeVec(chiaServiceFarmer, "last_lookup_time", "Lookup time for the last farmer_info event", []string{"host", "node_id"}) + + // Debug Metric + s.debug = s.metrics.newGaugeVec(chiaServiceFarmer, "debug_metrics", "random debugging metrics distinguished by labels", []string{"key"}) } // InitialData is called on startup of the metrics server, to allow seeding metrics with current/initial data @@ -117,6 +123,8 @@ func (s *FarmerServiceMetrics) ReceiveResponse(resp *types.WebsocketResponse) { fallthrough case "close_connection": utils.LogErr(s.metrics.client.FarmerService.GetConnections(&rpc.GetConnectionsOptions{})) + case "debug": + debugHelper(resp, s.debug) } } diff --git a/internal/metrics/fullnode.go b/internal/metrics/fullnode.go index 7ff26db..b01ffcf 100644 --- a/internal/metrics/fullnode.go +++ b/internal/metrics/fullnode.go @@ -127,7 +127,7 @@ func (s *FullNodeServiceMetrics) InitMetrics() { s.subEpochSummaries = s.metrics.newGauge(chiaServiceFullNode, "sub_epoch_summaries_filesize", "Size of sub_epoch_summaries file") // Debug Metric - s.debug = s.metrics.newGaugeVec(chiaServiceFullNode, "debug_metrics", "random debugging metrics distinguished by labels", []string{"key"}) + s.debug = s.metrics.newGaugeVec(chiaServiceFullNode, "debug_metrics", "misc debugging metrics distinguished by labels", []string{"key"}) } // InitialData is called on startup of the metrics server, to allow seeding metrics with diff --git a/internal/metrics/harvester.go b/internal/metrics/harvester.go index b04fd81..f08b708 100644 --- a/internal/metrics/harvester.go +++ b/internal/metrics/harvester.go @@ -38,6 +38,9 @@ type HarvesterServiceMetrics struct { totalEligiblePlots *wrappedPrometheus.LazyCounter lastEligiblePlots *wrappedPrometheus.LazyGauge lastLookupTime *wrappedPrometheus.LazyGauge + + // Debug Metric + debug *prometheus.GaugeVec } // InitMetrics sets all the metrics properties @@ -57,6 +60,9 @@ func (s *HarvesterServiceMetrics) InitMetrics() { s.lastEligiblePlots = s.metrics.newGauge(chiaServiceHarvester, "last_eligible_plots", "Number of eligible plots for the last farmer_info event") s.lastLookupTime = s.metrics.newGauge(chiaServiceHarvester, "last_lookup_time", "Lookup time for the last farmer_info event") + + // Debug Metric + s.debug = s.metrics.newGaugeVec(chiaServiceHarvester, "debug_metrics", "random debugging metrics distinguished by labels", []string{"key"}) } // InitialData is called on startup of the metrics server, to allow seeding metrics with current/initial data @@ -111,6 +117,8 @@ func (s *HarvesterServiceMetrics) ReceiveResponse(resp *types.WebsocketResponse) s.FarmingInfo(resp) case "get_plots": s.GetPlots(resp) + case "debug": + debugHelper(resp, s.debug) } } diff --git a/internal/metrics/timelord.go b/internal/metrics/timelord.go index 3c1380b..91bf740 100644 --- a/internal/metrics/timelord.go +++ b/internal/metrics/timelord.go @@ -25,6 +25,9 @@ type TimelordServiceMetrics struct { slowTimelord *wrappedPrometheus.LazyCounter estimatedIPS *wrappedPrometheus.LazyGauge compactProofsFound *prometheus.CounterVec + + // Debug Metric + debug *prometheus.GaugeVec } // InitMetrics sets all the metrics properties @@ -33,6 +36,9 @@ func (s *TimelordServiceMetrics) InitMetrics() { s.slowTimelord = s.metrics.newCounter(chiaServiceTimelord, "slow_timelord", "Counter for how many times this timelord has NOT been the fastest since the exporter has been running") s.estimatedIPS = s.metrics.newGauge(chiaServiceTimelord, "estimated_ips", "Current estimated IPS. Updated every time a new PoT Challenge is complete") s.compactProofsFound = s.metrics.newCounterVec(chiaServiceTimelord, "compact_proofs_completed", "Count of the number of compact proofs by proof type since the exporter was started", []string{"vdf_field"}) + + // Debug Metric + s.debug = s.metrics.newGaugeVec(chiaServiceTimelord, "debug_metrics", "random debugging metrics distinguished by labels", []string{"key"}) } // InitialData is called on startup of the metrics server, to allow seeding metrics with @@ -69,6 +75,8 @@ func (s *TimelordServiceMetrics) ReceiveResponse(resp *types.WebsocketResponse) s.SkippingPeak(resp) case "new_peak": s.NewPeak(resp) + case "debug": + debugHelper(resp, s.debug) } } diff --git a/internal/metrics/wallet.go b/internal/metrics/wallet.go index a56f089..688f9db 100644 --- a/internal/metrics/wallet.go +++ b/internal/metrics/wallet.go @@ -33,6 +33,9 @@ type WalletServiceMetrics struct { maxSendAmount *prometheus.GaugeVec pendingCoinRemovalCount *prometheus.GaugeVec unspentCoinCount *prometheus.GaugeVec + + // Debug Metric + debug *prometheus.GaugeVec } // InitMetrics sets all the metrics properties @@ -48,6 +51,9 @@ func (s *WalletServiceMetrics) InitMetrics() { s.maxSendAmount = s.metrics.newGaugeVec(chiaServiceWallet, "max_send_amount", "", walletLabels) s.pendingCoinRemovalCount = s.metrics.newGaugeVec(chiaServiceWallet, "pending_coin_removal_count", "", walletLabels) s.unspentCoinCount = s.metrics.newGaugeVec(chiaServiceWallet, "unspent_coin_count", "", walletLabels) + + // Debug Metric + s.debug = s.metrics.newGaugeVec(chiaServiceWallet, "debug_metrics", "misc debugging metrics distinguished by labels", []string{"key"}) } // InitialData is called on startup of the metrics server, to allow seeding metrics with @@ -98,6 +104,8 @@ func (s *WalletServiceMetrics) ReceiveResponse(resp *types.WebsocketResponse) { s.GetWalletBalance(resp) case "get_wallets": s.GetWallets(resp) + case "debug": + debugHelper(resp, s.debug) } }