Skip to content

Commit

Permalink
fix: have status=error on bad RPC nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jlehtimaki committed Oct 31, 2023
1 parent bb9794c commit bceaf10
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 41 deletions.
82 changes: 42 additions & 40 deletions pkg/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package collector
import (
"fmt"
"math/big"
"reflect"
"sync"

"github.com/cosmos/relayer/v2/relayer"
Expand Down Expand Up @@ -132,49 +133,50 @@ func (cc IBCCollector) Collect(ch chan<- prometheus.Metric) {
if err != nil {
status = errorStatus

fmt.Println("FOOOOBAAAAR")
log.Error(err.Error())
}

for _, sp := range stuckPackets.Channels {
ch <- prometheus.MustNewConstMetric(
channelStuckPackets,
prometheus.GaugeValue,
float64(sp.StuckPackets.Total),
[]string{
sp.Source,
sp.Destination,
(*cc.RPCs)[path.Chain1.ChainName].ChainID,
(*cc.RPCs)[path.Chain2.ChainName].ChainID,
status,
}...,
)

ch <- prometheus.MustNewConstMetric(
channelSrcStuckPackets,
prometheus.GaugeValue,
float64(sp.StuckPackets.Source),
[]string{
sp.Source,
sp.Destination,
(*cc.RPCs)[path.Chain1.ChainName].ChainID,
(*cc.RPCs)[path.Chain2.ChainName].ChainID,
status,
}...,
)

ch <- prometheus.MustNewConstMetric(
channelDstStuckPackets,
prometheus.GaugeValue,
float64(sp.StuckPackets.Destination),
[]string{
sp.Source,
sp.Destination,
(*cc.RPCs)[path.Chain1.ChainName].ChainID,
(*cc.RPCs)[path.Chain2.ChainName].ChainID,
status,
}...,
)
if !reflect.DeepEqual(stuckPackets, ibc.ChannelsInfo{}) {
for _, sp := range stuckPackets.Channels {
ch <- prometheus.MustNewConstMetric(
channelStuckPackets,
prometheus.GaugeValue,
float64(sp.StuckPackets.Total),
[]string{
sp.Source,
sp.Destination,
(*cc.RPCs)[path.Chain1.ChainName].ChainID,
(*cc.RPCs)[path.Chain2.ChainName].ChainID,
status,
}...,
)

ch <- prometheus.MustNewConstMetric(
channelSrcStuckPackets,
prometheus.GaugeValue,
float64(sp.StuckPackets.Source),
[]string{
sp.Source,
sp.Destination,
(*cc.RPCs)[path.Chain1.ChainName].ChainID,
(*cc.RPCs)[path.Chain2.ChainName].ChainID,
status,
}...,
)

ch <- prometheus.MustNewConstMetric(
channelDstStuckPackets,
prometheus.GaugeValue,
float64(sp.StuckPackets.Destination),
[]string{
sp.Source,
sp.Destination,
(*cc.RPCs)[path.Chain1.ChainName].ChainID,
(*cc.RPCs)[path.Chain2.ChainName].ChainID,
status,
}...,
)
}
}
}(p)
}
Expand Down
11 changes: 10 additions & 1 deletion pkg/ibc/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type ClientsInfo struct {
}

type ChannelsInfo struct {
ChainA *relayer.Chain
ChainB *relayer.Chain
Channels []Channel
}

Expand Down Expand Up @@ -126,7 +128,14 @@ func GetChannelsInfo(ibc *relayer.IBCdata, rpcs *map[string]config.RPC) (Channel
if _, _, err := relayer.QueryLatestHeights(
ctx, chainA, chainB,
); err != nil {
return ChannelsInfo{}, fmt.Errorf("Error: %w for %v", err, cdA)
for _, c := range ibc.Channels {
var channel Channel
channel.Source = c.Chain1.ChannelID
channel.Destination = c.Chain2.ChannelID
channelInfo.Channels = append(channelInfo.Channels, channel)
}

return channelInfo, fmt.Errorf("Error: %w for %v", err, cdA)
}

for _, c := range ibc.Channels {
Expand Down

0 comments on commit bceaf10

Please sign in to comment.