Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Clean up obsolete metric
Browse files Browse the repository at this point in the history
  • Loading branch information
eitu5ami committed Feb 16, 2024
1 parent d0d8d7d commit ac417f7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 32 deletions.
9 changes: 0 additions & 9 deletions internal/proxy/healthchecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
const (
MetricBlockNumber int = iota
MetricGasLimit
MetricResponseTime
)

const (
Expand Down Expand Up @@ -87,7 +86,6 @@ type RPCHealthchecker struct {
mu sync.RWMutex

// metrics
metricResponseTime *prometheus.HistogramVec
metricRPCProviderBlockNumber *prometheus.GaugeVec
metricRPCProviderGasLimit *prometheus.GaugeVec
}
Expand Down Expand Up @@ -121,8 +119,6 @@ func (h *RPCHealthchecker) SetMetric(i int, metric interface{}) {
h.metricRPCProviderBlockNumber = metric.(*prometheus.GaugeVec)
case MetricGasLimit:
h.metricRPCProviderGasLimit = metric.(*prometheus.GaugeVec)
case MetricResponseTime:
h.metricResponseTime = metric.(*prometheus.HistogramVec)
default:
zap.L().Warn("invalid metric type, ignoring.")
}
Expand All @@ -133,16 +129,11 @@ func (h *RPCHealthchecker) checkBlockNumber(ctx context.Context) (uint64, error)
// used to evaluate a single RPC node against others
var blockNumber hexutil.Uint64

start := time.Now()
err := h.client.CallContext(ctx, &blockNumber, "eth_blockNumber")
if err != nil {
zap.L().Warn("error fetching the block number", zap.Error(err), zap.String("name", h.config.Name))
return 0, err
}
duration := time.Since(start)
if h.metricResponseTime != nil {
h.metricResponseTime.WithLabelValues(h.config.Name, "eth_blockNumber").Observe(duration.Seconds())
}
if h.metricRPCProviderBlockNumber != nil {
h.metricRPCProviderBlockNumber.WithLabelValues(h.config.Name).Set(float64(blockNumber))
}
Expand Down
23 changes: 0 additions & 23 deletions internal/proxy/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type HealthcheckManager struct {

metricRPCProviderInfo *prometheus.GaugeVec
metricRPCProviderStatus *prometheus.GaugeVec
metricResponseTime *prometheus.HistogramVec
metricRPCProviderBlockNumber *prometheus.GaugeVec
metricRPCProviderGasLimit *prometheus.GaugeVec
}
Expand All @@ -45,27 +44,6 @@ func NewHealthcheckManager(config HealthcheckManagerConfig) *HealthcheckManager
"provider",
"type",
}),
metricResponseTime: promauto.NewHistogramVec(
prometheus.HistogramOpts{
Name: "zeroex_rpc_gateway_healthcheck_response_duration_seconds",
Help: "Histogram of response time for Gateway Healthchecker in seconds",
Buckets: []float64{
.005,
.01,
.025,
.05,
.1,
.25,
.5,
1,
2.5,
5,
10,
},
}, []string{
"provider",
"method",
}),
metricRPCProviderBlockNumber: promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "zeroex_rpc_gateway_provider_block_number",
Expand Down Expand Up @@ -95,7 +73,6 @@ func NewHealthcheckManager(config HealthcheckManagerConfig) *HealthcheckManager

healthchecker.SetMetric(MetricBlockNumber, healthcheckManager.metricRPCProviderBlockNumber)
healthchecker.SetMetric(MetricGasLimit, healthcheckManager.metricRPCProviderGasLimit)
healthchecker.SetMetric(MetricResponseTime, healthcheckManager.metricResponseTime)

if err != nil {
panic(err)
Expand Down

0 comments on commit ac417f7

Please sign in to comment.