feat: add metric for block gossip time (#12670)

This commit is contained in:
terencechain 2023-07-27 08:17:24 -07:00 committed by GitHub
parent 183e72b194
commit a44c209be0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -125,6 +125,12 @@ var (
Help: "Time to verify gossiped blocks",
},
)
blockArrivalGossipSummary = promauto.NewSummary(
prometheus.SummaryOpts{
Name: "gossip_block_arrival_milliseconds",
Help: "Time for gossiped blocks to arrive",
},
)
// Sync committee verification performance.
syncMessagesForUnknownBlocks = promauto.NewCounter(

View File

@ -200,15 +200,20 @@ func (s *Service) validateBeaconBlockPubSub(ctx context.Context, pid peer.ID, ms
return pubsub.ValidationIgnore, err
}
graffiti := blk.Block().Body().Graffiti()
sinceSlotStartTime := receivedTime.Sub(startTime)
validationTime := prysmTime.Now().Sub(receivedTime)
log.WithFields(logrus.Fields{
"blockSlot": blk.Block().Slot(),
"sinceSlotStartTime": receivedTime.Sub(startTime),
"validationTime": prysmTime.Now().Sub(receivedTime),
"sinceSlotStartTime": sinceSlotStartTime,
"validationTime": validationTime,
"proposerIndex": blk.Block().ProposerIndex(),
"graffiti": string(graffiti[:]),
}).Debug("Received block")
blockVerificationGossipSummary.Observe(float64(prysmTime.Since(receivedTime).Milliseconds()))
blockArrivalGossipSummary.Observe(float64(sinceSlotStartTime))
blockVerificationGossipSummary.Observe(float64(validationTime))
return pubsub.ValidationAccept, nil
}