Skip to content

Commit

Permalink
fix(collector.go): use big.Int instead of Int
Browse files Browse the repository at this point in the history
  • Loading branch information
incubator4 committed Mar 1, 2024
1 parent 5a0807d commit 602b444
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions exporter/collector.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package exporter

import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/naturalselectionlabs/geth-exporter/config"
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/zap"
"strconv"
)

type GethMetricsCollector struct {
Expand Down Expand Up @@ -32,17 +32,18 @@ func (g GethMetricsCollector) Collect(metrics chan<- prometheus.Metric) {
case config.HexResult:
value, ok := g.Result.(string)
if ok {
i, err := strconv.ParseInt(value, 0, 64)
i, err := hexutil.DecodeBig(value)
if err != nil {
zap.L().Error("Error convert", zap.Error(err))
} else {
metrics <- prometheus.MustNewConstMetric(
g.Metrics.Desc,
g.Metrics.ValueType,
float64(i),
g.Metrics.LabelValues...,
)
return
}
f, _ := i.Float64()
metrics <- prometheus.MustNewConstMetric(
g.Metrics.Desc,
g.Metrics.ValueType,
f,
g.Metrics.LabelValues...,
)

}
}
Expand Down

0 comments on commit 602b444

Please sign in to comment.