Skip to content

Commit

Permalink
fix eth_block_timestamp and added error wrapper to parity metrics (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
evictorero committed Mar 8, 2022
1 parent bed5c5d commit 23de33f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/collector/eth_block_timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (collector *EthBlockTimestamp) Describe(ch chan<- *prometheus.Desc) {
func (collector *EthBlockTimestamp) Collect(ch chan<- prometheus.Metric) {
var result *blockResult

if err := collector.rpc.Call(&result, "eth_getBlockByNumber", "latest", 0); err != nil {
if err := collector.rpc.Call(&result, "eth_getBlockByNumber", "latest", false); err != nil {
ch <- prometheus.NewInvalidMetric(collector.desc, err)
return
}
Expand Down
6 changes: 4 additions & 2 deletions internal/collector/parity_net_peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package collector

import (
"github.com/ethereum/go-ethereum/rpc"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
)

Expand Down Expand Up @@ -42,8 +43,9 @@ func (collector *ParityNetPeers) Describe(ch chan<- *prometheus.Desc) {
func (collector *ParityNetPeers) Collect(ch chan<- prometheus.Metric) {
var result *peersResult
if err := collector.rpc.Call(&result, "parity_netPeers"); err != nil {
ch <- prometheus.NewInvalidMetric(collector.activeDesc, err)
ch <- prometheus.NewInvalidMetric(collector.connectedDesc, err)
wErr := errors.Wrap(err, "parity metrics are only available in OpenEthereum")
ch <- prometheus.NewInvalidMetric(collector.activeDesc, wErr)
ch <- prometheus.NewInvalidMetric(collector.connectedDesc, wErr)
return
}

Expand Down

0 comments on commit 23de33f

Please sign in to comment.