diff --git a/internal/metrics/crawler.go b/internal/metrics/crawler.go index 780046c..2b8816f 100644 --- a/internal/metrics/crawler.go +++ b/internal/metrics/crawler.go @@ -30,6 +30,7 @@ type CrawlerServiceMetrics struct { metrics *Metrics // General Service Metrics + gotVersionResponse bool version *prometheus.GaugeVec // Current network @@ -128,6 +129,7 @@ func (s *CrawlerServiceMetrics) SetupPollingMetrics(ctx context.Context) {} // Disconnected clears/unregisters metrics when the connection drops func (s *CrawlerServiceMetrics) Disconnected() { s.version.Reset() + s.gotVersionResponse = false s.totalNodes5Days.Unregister() s.reliableNodes.Unregister() s.ipv4Nodes5Days.Unregister() @@ -143,9 +145,18 @@ func (s *CrawlerServiceMetrics) Reconnected() { // ReceiveResponse handles crawler responses that are returned over the websocket func (s *CrawlerServiceMetrics) ReceiveResponse(resp *types.WebsocketResponse) { + // Sometimes, when we reconnect, or start exporter before chia is running + // the daemon is up before the service, and the initial request for the version + // doesn't make it to the service + // daemon doesn't queue these messages for later, they just get dropped + if !s.gotVersionResponse { + utils.LogErr(s.metrics.client.FullNodeService.GetVersion(&rpc.GetVersionOptions{})) + } + switch resp.Command { case "get_version": versionHelper(resp, s.version) + s.gotVersionResponse = true case "get_peer_counts": fallthrough case "loaded_initial_peers": diff --git a/internal/metrics/farmer.go b/internal/metrics/farmer.go index 17ee97b..ed3a1e9 100644 --- a/internal/metrics/farmer.go +++ b/internal/metrics/farmer.go @@ -24,6 +24,7 @@ type FarmerServiceMetrics struct { metrics *Metrics // General Service Metrics + gotVersionResponse bool version *prometheus.GaugeVec // Connection Metrics @@ -108,6 +109,7 @@ func (s *FarmerServiceMetrics) SetupPollingMetrics(ctx context.Context) {} // Disconnected clears/unregisters metrics when the connection drops func (s *FarmerServiceMetrics) Disconnected() { s.version.Reset() + s.gotVersionResponse = false s.connectionCount.Reset() s.plotFilesize.Reset() s.plotCount.Reset() @@ -123,9 +125,18 @@ func (s *FarmerServiceMetrics) Reconnected() { // ReceiveResponse handles crawler responses that are returned over the websocket func (s *FarmerServiceMetrics) ReceiveResponse(resp *types.WebsocketResponse) { + // Sometimes, when we reconnect, or start exporter before chia is running + // the daemon is up before the service, and the initial request for the version + // doesn't make it to the service + // daemon doesn't queue these messages for later, they just get dropped + if !s.gotVersionResponse { + utils.LogErr(s.metrics.client.FullNodeService.GetVersion(&rpc.GetVersionOptions{})) + } + switch resp.Command { case "get_version": versionHelper(resp, s.version) + s.gotVersionResponse = true case "get_connections": s.GetConnections(resp) case "new_farming_info": diff --git a/internal/metrics/fullnode.go b/internal/metrics/fullnode.go index f445421..5d65d21 100644 --- a/internal/metrics/fullnode.go +++ b/internal/metrics/fullnode.go @@ -230,9 +230,9 @@ func (s *FullNodeServiceMetrics) Reconnected() { // ReceiveResponse handles full node related responses that are returned over the websocket func (s *FullNodeServiceMetrics) ReceiveResponse(resp *types.WebsocketResponse) { - // Sometimes, when we reconnect, or start exporter before the full node is up - // the daemon is up before the full node, and the initial request for the version - // doesn't make it to the service, since it wasn't up yet + // Sometimes, when we reconnect, or start exporter before chia is running + // the daemon is up before the service, and the initial request for the version + // doesn't make it to the service // daemon doesn't queue these messages for later, they just get dropped if !s.gotVersionResponse { utils.LogErr(s.metrics.client.FullNodeService.GetVersion(&rpc.GetVersionOptions{})) diff --git a/internal/metrics/harvester.go b/internal/metrics/harvester.go index 6595a4c..2144a62 100644 --- a/internal/metrics/harvester.go +++ b/internal/metrics/harvester.go @@ -25,6 +25,7 @@ type HarvesterServiceMetrics struct { metrics *Metrics // General Service Metrics + gotVersionResponse bool version *prometheus.GaugeVec // Connection Metrics @@ -124,6 +125,7 @@ func (s *HarvesterServiceMetrics) httpGetPlots() { // Disconnected clears/unregisters metrics when the connection drops func (s *HarvesterServiceMetrics) Disconnected() { s.version.Reset() + s.gotVersionResponse = false s.connectionCount.Reset() s.totalPlots.Unregister() s.plotFilesize.Reset() @@ -140,9 +142,18 @@ func (s *HarvesterServiceMetrics) Reconnected() { // ReceiveResponse handles crawler responses that are returned over the websocket func (s *HarvesterServiceMetrics) ReceiveResponse(resp *types.WebsocketResponse) { + // Sometimes, when we reconnect, or start exporter before chia is running + // the daemon is up before the service, and the initial request for the version + // doesn't make it to the service + // daemon doesn't queue these messages for later, they just get dropped + if !s.gotVersionResponse { + utils.LogErr(s.metrics.client.FullNodeService.GetVersion(&rpc.GetVersionOptions{})) + } + switch resp.Command { case "get_version": versionHelper(resp, s.version) + s.gotVersionResponse = true case "get_connections": s.GetConnections(resp) case "farming_info": diff --git a/internal/metrics/timelord.go b/internal/metrics/timelord.go index bb1b48a..2983752 100644 --- a/internal/metrics/timelord.go +++ b/internal/metrics/timelord.go @@ -23,6 +23,7 @@ type TimelordServiceMetrics struct { metrics *Metrics // General Service Metrics + gotVersionResponse bool version *prometheus.GaugeVec // Timelord Metrics @@ -62,6 +63,7 @@ func (s *TimelordServiceMetrics) SetupPollingMetrics(ctx context.Context) {} // Disconnected clears/unregisters metrics when the connection drops func (s *TimelordServiceMetrics) Disconnected() { s.version.Reset() + s.gotVersionResponse = false s.fastestTimelord.Unregister() s.slowTimelord.Unregister() s.estimatedIPS.Unregister() @@ -75,10 +77,19 @@ func (s *TimelordServiceMetrics) Reconnected() { // ReceiveResponse handles crawler responses that are returned over the websocket func (s *TimelordServiceMetrics) ReceiveResponse(resp *types.WebsocketResponse) { + // Sometimes, when we reconnect, or start exporter before chia is running + // the daemon is up before the service, and the initial request for the version + // doesn't make it to the service + // daemon doesn't queue these messages for later, they just get dropped + if !s.gotVersionResponse { + utils.LogErr(s.metrics.client.FullNodeService.GetVersion(&rpc.GetVersionOptions{})) + } + //("finished_pot_challenge", "new_compact_proof", "skipping_peak", "new_peak") switch resp.Command { case "get_version": versionHelper(resp, s.version) + s.gotVersionResponse = true case "finished_pot": s.FinishedPoT(resp) case "new_compact_proof": diff --git a/internal/metrics/wallet.go b/internal/metrics/wallet.go index 4acaad3..9e82a1f 100644 --- a/internal/metrics/wallet.go +++ b/internal/metrics/wallet.go @@ -25,6 +25,7 @@ type WalletServiceMetrics struct { metrics *Metrics // General Service Metrics + gotVersionResponse bool version *prometheus.GaugeVec // Connection Metrics @@ -93,6 +94,7 @@ func (s *WalletServiceMetrics) SetupPollingMetrics(ctx context.Context) { // Disconnected clears/unregisters metrics when the connection drops func (s *WalletServiceMetrics) Disconnected() { s.version.Reset() + s.gotVersionResponse = false s.connectionCount.Reset() s.walletSynced.Unregister() s.confirmedBalance.Reset() @@ -109,9 +111,18 @@ func (s *WalletServiceMetrics) Reconnected() { // ReceiveResponse handles wallet responses that are returned over the websocket func (s *WalletServiceMetrics) ReceiveResponse(resp *types.WebsocketResponse) { + // Sometimes, when we reconnect, or start exporter before chia is running + // the daemon is up before the service, and the initial request for the version + // doesn't make it to the service + // daemon doesn't queue these messages for later, they just get dropped + if !s.gotVersionResponse { + utils.LogErr(s.metrics.client.FullNodeService.GetVersion(&rpc.GetVersionOptions{})) + } + switch resp.Command { case "get_version": versionHelper(resp, s.version) + s.gotVersionResponse = true case "get_connections": s.GetConnections(resp) case "coin_added":