mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 07:58:22 -05:00
Add sync/p2p metric for number of messages received by topic (#3341)
* Add going msg metric * fmt * rename
This commit is contained in:
committed by
Raul Jordan
parent
7bb5ac0dde
commit
2ee4f00b81
@@ -48,6 +48,8 @@ go_library(
|
||||
"@com_github_libp2p_go_libp2p_core//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_core//network:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_prometheus_client_golang//prometheus:go_default_library",
|
||||
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
|
||||
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
],
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
package sync
|
||||
|
||||
import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
|
||||
// TODO(3147): Add metrics for RPC & subscription success/error.
|
||||
|
||||
var (
|
||||
messageReceivedCounter = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "p2p_message_recieved_total",
|
||||
Help: "Count of messages received.",
|
||||
},
|
||||
[]string{"topic"},
|
||||
)
|
||||
)
|
||||
|
||||
@@ -12,10 +12,10 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
|
||||
)
|
||||
|
||||
var oneYear = 365 * 24 * time.Hour
|
||||
const oneYear = 365 * 24 * time.Hour
|
||||
|
||||
// prefix to add to keys, so that we can represent invalid objects
|
||||
var invalid = "invalidObject"
|
||||
const invalid = "invalidObject"
|
||||
|
||||
// subHandler represents handler for a given subscription.
|
||||
type subHandler func(context.Context, proto.Message) error
|
||||
@@ -132,6 +132,8 @@ func (r *RegularSync) subscribe(topic string, validate validator, handle subHand
|
||||
continue
|
||||
}
|
||||
|
||||
messageReceivedCounter.WithLabelValues(topic + r.p2p.Encoding().ProtocolSuffix()).Inc()
|
||||
|
||||
go pipeline(msg.Data)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user