add a metric to measure the attestation gossip validator (#15785)

This PR adds a Summary metric to measure the p2p topic validation time
for attestations arriving from the network. It times the
`validateCommitteeIndexBeaconAttestation` method.

The metric is called `gossip_attestation_verification_milliseconds`

**Acknowledgements**

- [x] I have read
[CONTRIBUTING.md](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md).
- [x] I have included a uniquely named [changelog fragment
file](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md#maintaining-changelogmd).
- [x] I have added a description to this PR with sufficient context for
reviewers to understand this PR.

---------

Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
This commit is contained in:
Bharath Vedartham
2025-11-22 03:27:19 +05:30
committed by GitHub
parent 55e2001a0b
commit b78c2c354b
3 changed files with 14 additions and 0 deletions

View File

@@ -133,6 +133,12 @@ var (
Help: "Time to verify gossiped attestations",
},
)
attestationVerificationGossipSummary = promauto.NewSummary(
prometheus.SummaryOpts{
Name: "gossip_attestation_verification_milliseconds",
Help: "Time to verify gossiped attestations",
},
)
blockVerificationGossipSummary = promauto.NewSummary(
prometheus.SummaryOpts{
Name: "gossip_block_verification_milliseconds",

View File

@@ -7,6 +7,7 @@ import (
"reflect"
"slices"
"strings"
"time"
"github.com/OffchainLabs/prysm/v7/beacon-chain/blockchain"
"github.com/OffchainLabs/prysm/v7/beacon-chain/core/blocks"
@@ -41,6 +42,11 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(
pid peer.ID,
msg *pubsub.Message,
) (pubsub.ValidationResult, error) {
start := time.Now()
defer func() {
attestationVerificationGossipSummary.Observe(float64(time.Since(start).Milliseconds()))
}()
if pid == s.cfg.p2p.PeerID() {
return pubsub.ValidationAccept, nil
}

View File

@@ -0,0 +1,2 @@
### Added
- prometheus metric `gossip_attestation_verification_milliseconds` to track attestation gossip topic validation latency.