MCPcopy
hub / github.com/canopy-network/canopy / UpdateTelemetry

Method UpdateTelemetry

controller/block.go:657–677  ·  view source on GitHub ↗

UpdateTelemetry() updates the prometheus metrics after 'committing' a block

(qc *lib.QuorumCertificate, block *lib.Block, blockProcessingTime time.Duration)

Source from the content-addressed store, hash-verified

655
656// UpdateTelemetry() updates the prometheus metrics after 'committing' a block
657func (c *Controller) UpdateTelemetry(qc *lib.QuorumCertificate, block *lib.Block, blockProcessingTime time.Duration) {
658 // create convenience variables
659 address, vdfIterations := crypto.NewAddressFromBytes(c.Address), uint64(0)
660 // attempt to get VDF iterations
661 if block.BlockHeader.Vdf != nil {
662 vdfIterations = block.BlockHeader.Vdf.Iterations
663 }
664 // update node metrics
665 c.Metrics.UpdateNodeMetrics(c.isSyncing.Load())
666 // update the block metrics
667 c.Metrics.UpdateBlockMetrics(block.BlockHeader.ProposerAddress, uint64(len(qc.Block)), block.BlockHeader.NumTxs, vdfIterations, blockProcessingTime)
668 // update validator metric
669 if v, _ := c.FSM.GetValidator(address); v != nil && v.StakedAmount != 0 {
670 isProducer, nonSigners, doubleSigners := c.getValidatorBehaviorMetrics(address, qc)
671 c.Metrics.UpdateValidator(address.String(), v.StakedAmount, v.UnstakingHeight != 0, v.MaxPausedHeight != 0, v.Delegate, v.Compound, isProducer, nonSigners, doubleSigners)
672 }
673 // update account metrics
674 if a, _ := c.FSM.GetAccount(address); a.Amount != 0 {
675 c.Metrics.UpdateAccount(address.String(), a.Amount)
676 }
677}
678
679// getValidatorBehaviorMetrics() gets metrics for validator behavior in this block
680func (c *Controller) getValidatorBehaviorMetrics(address crypto.AddressI, qc *lib.QuorumCertificate) (isProducer bool, nonSigners map[string]uint64, doubleSigners []crypto.AddressI) {

Callers 2

CommitCertificateMethod · 0.95

Calls 10

NewAddressFromBytesFunction · 0.92
UpdateNodeMetricsMethod · 0.80
LoadMethod · 0.80
UpdateBlockMetricsMethod · 0.80
UpdateValidatorMethod · 0.80
GetAccountMethod · 0.80
UpdateAccountMethod · 0.80
StringMethod · 0.65
GetValidatorMethod · 0.45

Tested by

no test coverage detected