Skip to content

Commit

Permalink
if version isn't set when receiving responses, try to get it again
Browse files Browse the repository at this point in the history
  • Loading branch information
cmmarslender committed Nov 30, 2024
1 parent 9194f59 commit fd194a2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/metrics/fullnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ type FullNodeServiceMetrics struct {
metrics *Metrics

// General Service Metrics
version *prometheus.GaugeVec
gotVersionResponse bool
version *prometheus.GaugeVec

// GetBlockchainState Metrics
difficulty *wrappedPrometheus.LazyGauge
Expand Down Expand Up @@ -187,6 +188,7 @@ func (s *FullNodeServiceMetrics) SetupPollingMetrics(ctx context.Context) {
// Disconnected clears/unregisters metrics when the connection drops
func (s *FullNodeServiceMetrics) Disconnected() {
s.version.Reset()
s.gotVersionResponse = false
s.difficulty.Unregister()
s.mempoolCost.Unregister()
s.mempoolMinFee.Reset()
Expand Down Expand Up @@ -228,9 +230,18 @@ 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
// 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_blockchain_state":
s.GetBlockchainState(resp)
// Ask for connection info when we get updated blockchain state
Expand Down

0 comments on commit fd194a2

Please sign in to comment.