add bridge metrics to Whisper and Waku (#1864)
This commit is contained in:
parent
76b5dc29dc
commit
e4b0a97cc5
|
@ -935,7 +935,7 @@ func (b *GethStatusBackend) injectAccountIntoServices() error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := st.InitProtocol(identity, b.appDB); err != nil {
|
||||
if err := st.InitProtocol(identity, b.appDB, logutils.ZapLogger()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -226,6 +226,7 @@ func (n *StatusNode) setupRPCClient() (err error) {
|
|||
|
||||
func (n *StatusNode) setupBridge() error {
|
||||
if !n.config.BridgeConfig.Enabled {
|
||||
log.Info("a Whisper-Waku bridge is disabled")
|
||||
return nil
|
||||
}
|
||||
var shh *whisper.Whisper
|
||||
|
@ -240,6 +241,8 @@ func (n *StatusNode) setupBridge() error {
|
|||
n.bridge = bridge.New(shh, wak, logutils.ZapLogger())
|
||||
n.bridge.Start()
|
||||
|
||||
log.Info("setup a Whisper-Waku bridge successfully")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,19 @@ var (
|
|||
Name: "waku_rate_limits_exceeded_total",
|
||||
Help: "Number of times the Waku rate limits were exceeded",
|
||||
}, []string{"type"})
|
||||
// bridging
|
||||
bridgeSent = prom.NewCounter(prom.CounterOpts{
|
||||
Name: "waku_bridge_sent_total",
|
||||
Help: "Number of envelopes bridged from Waku",
|
||||
})
|
||||
bridgeReceivedSucceed = prom.NewCounter(prom.CounterOpts{
|
||||
Name: "waku_bridge_received_success_total",
|
||||
Help: "Number of envelopes bridged to Waku and successfully added",
|
||||
})
|
||||
bridgeReceivedFailed = prom.NewCounter(prom.CounterOpts{
|
||||
Name: "waku_bridge_received_failure_total",
|
||||
Help: "Number of envelopes bridged to Waku and failed to be added",
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -67,4 +80,7 @@ func init() {
|
|||
prom.MustRegister(envelopesSizeMeter)
|
||||
prom.MustRegister(rateLimitsProcessed)
|
||||
prom.MustRegister(rateLimitsExceeded)
|
||||
prom.MustRegister(bridgeSent)
|
||||
prom.MustRegister(bridgeReceivedSucceed)
|
||||
prom.MustRegister(bridgeReceivedFailed)
|
||||
}
|
||||
|
|
|
@ -375,12 +375,14 @@ func (w *Waku) readBridgeLoop() {
|
|||
case env := <-out:
|
||||
_, err := w.addAndBridge(env, false, true)
|
||||
if err != nil {
|
||||
bridgeReceivedFailed.Inc()
|
||||
w.logger.Warn(
|
||||
"failed to add a bridged envelope",
|
||||
zap.Binary("ID", env.Hash().Bytes()),
|
||||
zap.Error(err),
|
||||
)
|
||||
} else {
|
||||
bridgeReceivedSucceed.Inc()
|
||||
w.logger.Debug("bridged envelope successfully", zap.Binary("ID", env.Hash().Bytes()))
|
||||
w.envelopeFeed.Send(EnvelopeEvent{
|
||||
Event: EventEnvelopeReceived,
|
||||
|
@ -1309,8 +1311,10 @@ func (w *Waku) addAndBridge(envelope *Envelope, isP2P bool, bridged bool) (bool,
|
|||
// In particular, if a node is a lightweight node,
|
||||
// it should not bridge any envelopes.
|
||||
if !isP2P && !bridged && w.bridge != nil {
|
||||
log.Debug("bridging envelope from Waku", "hash", envelope.Hash().Hex())
|
||||
_, in := w.bridge.Pipe()
|
||||
in <- envelope
|
||||
bridgeSent.Inc()
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
|
|
|
@ -39,6 +39,19 @@ var (
|
|||
Name: "whisper_rate_limits_exceeded_total",
|
||||
Help: "Number of times the Waku rate limits were exceeded",
|
||||
}, []string{"type"})
|
||||
// bridging
|
||||
bridgeSent = prom.NewCounter(prom.CounterOpts{
|
||||
Name: "whisper_bridge_sent_total",
|
||||
Help: "Number of envelopes bridged from Whisper",
|
||||
})
|
||||
bridgeReceivedSucceed = prom.NewCounter(prom.CounterOpts{
|
||||
Name: "whisper_bridge_received_success_total",
|
||||
Help: "Number of envelopes bridged to Whisper and successfully added",
|
||||
})
|
||||
bridgeReceivedFailed = prom.NewCounter(prom.CounterOpts{
|
||||
Name: "whisper_bridge_received_failure_total",
|
||||
Help: "Number of envelopes bridged to Whisper and failed to be added",
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -49,4 +62,7 @@ func init() {
|
|||
prom.MustRegister(envelopesSizeMeter)
|
||||
prom.MustRegister(rateLimitsProcessed)
|
||||
prom.MustRegister(rateLimitsExceeded)
|
||||
prom.MustRegister(bridgeSent)
|
||||
prom.MustRegister(bridgeReceivedSucceed)
|
||||
prom.MustRegister(bridgeReceivedFailed)
|
||||
}
|
||||
|
|
|
@ -301,12 +301,14 @@ func (whisper *Whisper) readBridgeLoop() {
|
|||
case env := <-out:
|
||||
_, err := whisper.addAndBridge(env, false, true)
|
||||
if err != nil {
|
||||
bridgeReceivedFailed.Inc()
|
||||
log.Warn(
|
||||
"failed to add a bridged envelope",
|
||||
"ID", env.Hash().Bytes(),
|
||||
"err", err,
|
||||
)
|
||||
} else {
|
||||
bridgeReceivedSucceed.Inc()
|
||||
log.Debug(
|
||||
"bridged envelope successfully",
|
||||
"ID", env.Hash().Bytes(),
|
||||
|
@ -1375,8 +1377,10 @@ func (whisper *Whisper) addAndBridge(envelope *Envelope, isP2P bool, bridged boo
|
|||
// In particular, if a node is a lightweight node,
|
||||
// it should not bridge any envelopes.
|
||||
if !isP2P && !bridged && whisper.bridge != nil {
|
||||
log.Debug("bridging envelope from Whisper", "hash", envelope.Hash().Hex())
|
||||
_, in := whisper.bridge.Pipe()
|
||||
in <- envelope
|
||||
bridgeSent.Inc()
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
|
|
Loading…
Reference in New Issue