mirror of https://github.com/status-im/go-waku.git
fix: remove bandwidth metrics that were commited to `master` by mistake
This commit is contained in:
parent
244bb176eb
commit
ae423936ed
|
@ -3,7 +3,6 @@ package node
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p/core/metrics"
|
|
||||||
"github.com/libp2p/go-libp2p/p2p/metricshelper"
|
"github.com/libp2p/go-libp2p/p2p/metricshelper"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
@ -34,20 +33,11 @@ var peerStoreSize = prometheus.NewGauge(
|
||||||
Help: "Size of Peer Store",
|
Help: "Size of Peer Store",
|
||||||
})
|
})
|
||||||
|
|
||||||
var bandwidthTotal = prometheus.NewCounterVec(
|
|
||||||
prometheus.CounterOpts{
|
|
||||||
Name: "libp2p_network_bytes_total",
|
|
||||||
Help: "Bandwidth usage total",
|
|
||||||
},
|
|
||||||
[]string{"direction"},
|
|
||||||
)
|
|
||||||
|
|
||||||
var collectors = []prometheus.Collector{
|
var collectors = []prometheus.Collector{
|
||||||
gitVersion,
|
gitVersion,
|
||||||
peerDials,
|
peerDials,
|
||||||
connectedPeers,
|
connectedPeers,
|
||||||
peerStoreSize,
|
peerStoreSize,
|
||||||
bandwidthTotal,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Metrics exposes the functions required to update prometheus metrics for the waku node
|
// Metrics exposes the functions required to update prometheus metrics for the waku node
|
||||||
|
@ -57,7 +47,6 @@ type Metrics interface {
|
||||||
RecordPeerConnected()
|
RecordPeerConnected()
|
||||||
RecordPeerDisconnected()
|
RecordPeerDisconnected()
|
||||||
SetPeerStoreSize(int)
|
SetPeerStoreSize(int)
|
||||||
RecordBandwidth(metrics.Stats)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type metricsImpl struct {
|
type metricsImpl struct {
|
||||||
|
@ -95,9 +84,3 @@ func (m *metricsImpl) RecordPeerDisconnected() {
|
||||||
func (m *metricsImpl) SetPeerStoreSize(size int) {
|
func (m *metricsImpl) SetPeerStoreSize(size int) {
|
||||||
peerStoreSize.Set(float64(size))
|
peerStoreSize.Set(float64(size))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *metricsImpl) RecordBandwidth(stats metrics.Stats) {
|
|
||||||
bandwidthTotal.WithLabelValues("in").Add(float64(stats.TotalIn))
|
|
||||||
bandwidthTotal.WithLabelValues("out").Add(float64(stats.TotalOut))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import (
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p/core/event"
|
"github.com/libp2p/go-libp2p/core/event"
|
||||||
"github.com/libp2p/go-libp2p/core/host"
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
"github.com/libp2p/go-libp2p/core/metrics"
|
|
||||||
"github.com/libp2p/go-libp2p/core/network"
|
"github.com/libp2p/go-libp2p/core/network"
|
||||||
"github.com/libp2p/go-libp2p/core/peer"
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
"github.com/libp2p/go-libp2p/core/peerstore"
|
"github.com/libp2p/go-libp2p/core/peerstore"
|
||||||
|
@ -85,12 +84,11 @@ type RLNRelay interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type WakuNode struct {
|
type WakuNode struct {
|
||||||
host host.Host
|
host host.Host
|
||||||
opts *WakuNodeParameters
|
opts *WakuNodeParameters
|
||||||
log *zap.Logger
|
log *zap.Logger
|
||||||
timesource timesource.Timesource
|
timesource timesource.Timesource
|
||||||
metrics Metrics
|
metrics Metrics
|
||||||
bandwidthCounter *metrics.BandwidthCounter
|
|
||||||
|
|
||||||
peerstore peerstore.Peerstore
|
peerstore peerstore.Peerstore
|
||||||
peerConnector *peermanager.PeerConnectionStrategy
|
peerConnector *peermanager.PeerConnectionStrategy
|
||||||
|
@ -197,9 +195,6 @@ func New(opts ...WakuNodeOption) (*WakuNode, error) {
|
||||||
w.metrics = newMetrics(params.prometheusReg)
|
w.metrics = newMetrics(params.prometheusReg)
|
||||||
w.metrics.RecordVersion(Version, GitCommit)
|
w.metrics.RecordVersion(Version, GitCommit)
|
||||||
|
|
||||||
w.bandwidthCounter = metrics.NewBandwidthCounter()
|
|
||||||
params.libP2POpts = append(params.libP2POpts, libp2p.BandwidthReporter(w.bandwidthCounter))
|
|
||||||
|
|
||||||
// Setup peerstore wrapper
|
// Setup peerstore wrapper
|
||||||
if params.peerstore != nil {
|
if params.peerstore != nil {
|
||||||
w.peerstore = wps.NewWakuPeerstore(params.peerstore)
|
w.peerstore = wps.NewWakuPeerstore(params.peerstore)
|
||||||
|
@ -364,23 +359,6 @@ func (w *WakuNode) Start(ctx context.Context) error {
|
||||||
|
|
||||||
w.host = host
|
w.host = host
|
||||||
|
|
||||||
// Bandwidth reporter created for comparing IDONTWANT performance
|
|
||||||
go func() {
|
|
||||||
ticker := time.NewTicker(time.Second)
|
|
||||||
defer ticker.Stop()
|
|
||||||
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-ctx.Done():
|
|
||||||
return
|
|
||||||
case <-ticker.C:
|
|
||||||
totals := w.bandwidthCounter.GetBandwidthTotals()
|
|
||||||
w.bandwidthCounter.Reset()
|
|
||||||
w.metrics.RecordBandwidth(totals)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
if w.addressChangesSub, err = host.EventBus().Subscribe(new(event.EvtLocalAddressesUpdated)); err != nil {
|
if w.addressChangesSub, err = host.EventBus().Subscribe(new(event.EvtLocalAddressesUpdated)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue