metrics

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BalanceScale          int = 18
	BalancePrecision      int = 13
	ConnectionsNumberPush int = 0
	BlockHeightPush       int = 1
	NodeBalancePush       int = 2
	LastConsensusPush     int = 3
	BlockRewardPush       int = 4
	TxPoolPush            int = 5
	IsLeaderPush          int = 6
)

Constants for metrics service.

View Source
const (
	BalancePrefix           = "bap"
	BlockHeightPrefix       = "bhp"
	BlocksPrefix            = "bp"
	BlockRewardPrefix       = "brp"
	ConnectionsNumberPrefix = "cnp"
	ConsensusTimePrefix     = "ltp"
	IsLeaderPrefix          = "ilp"
	TxPoolPrefix            = "tpp"
)

Constants for storage.

Variables

This section is empty.

Functions

func FormatBalance

func FormatBalance(balance *big.Int) float64

FormatBalance formats big.Int balance with precision.

func GetKey

func GetKey(prefix string, moment int64) string

GetKey returns key by prefix and pushed time momemnt.

func GetMetricsServicePort

func GetMetricsServicePort(nodePort string) string

GetMetricsServicePort returns the port serving metrics service dashboard. This port is metricsServicePortDifference less than the node port.

func UpdateBlockHeight

func UpdateBlockHeight(blockHeight uint64)

UpdateBlockHeight updates block height.

func UpdateBlockReward

func UpdateBlockReward(blockReward *big.Int)

UpdateBlockReward updates block reward.

func UpdateConnectionsNumber

func UpdateConnectionsNumber(connectionsNumber int)

UpdateConnectionsNumber updates connections number.

func UpdateIsLeader

func UpdateIsLeader(isLeader bool)

UpdateIsLeader updates if node is a leader.

func UpdateLastConsensus

func UpdateLastConsensus(consensusTime int64)

UpdateLastConsensus updates last consensus time.

func UpdateNodeBalance

func UpdateNodeBalance(balance *big.Int)

UpdateNodeBalance updates node balance.

func UpdateTxPoolSize

func UpdateTxPoolSize(txPoolSize uint64)

UpdateTxPoolSize updates tx pool size.

Types

type Service

type Service struct {
	BlsPublicKey    string
	IP              string
	Port            string
	PushgatewayIP   string
	PushgatewayPort string
	// contains filtered or unexported fields
}

Service is the struct for metrics service.

func New

func New(selfPeer *p2p.Peer, blsPublicKey, pushgatewayIP, pushgatewayPort string) *Service

New returns metrics service.

func (*Service) APIs

func (s *Service) APIs() []rpc.API

APIs for the services.

func (*Service) NotifyService

func (s *Service) NotifyService(params map[string]interface{})

NotifyService notify service

func (*Service) PushMetrics

func (s *Service) PushMetrics()

PushMetrics pushes metrics updates to prometheus pushgateway.

func (*Service) Run

func (s *Service) Run()

Run is to run http serving metrics service.

func (*Service) SetMessageChan

func (s *Service) SetMessageChan(messageChan chan *msg_pb.Message)

SetMessageChan sets up message channel to service.

func (*Service) StartService

func (s *Service) StartService()

StartService starts metrics service.

func (*Service) StopService

func (s *Service) StopService()

StopService shutdowns metrics service.

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage storage dump the block info into leveldb.

func GetStorageInstance

func GetStorageInstance(ip, port string, remove bool) *Storage

GetStorageInstance returns attack model by using singleton pattern.

func (*Storage) Dump

func (storage *Storage) Dump(value interface{}, prefix string) error

Dump data into lvdb by value and prefix.

func (*Storage) GetDB

func (storage *Storage) GetDB() *ethdb.LDBDatabase

GetDB returns the LDBDatabase of the storage.

func (*Storage) Init

func (storage *Storage) Init(ip, port string, remove bool)

Init initializes storage.

func (*Storage) Read

func (storage *Storage) Read(since, until int64, prefix string, varType interface{}) []interface{}

Read returns data list of a particular metric by since, until, prefix, interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL