metrics

package
v0.0.0-...-1329066 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package metrics provides metrics functionalities for the zetaclient

Index

Constants

View Source
const ZetaClientNamespace = "zetaclient"

ZetaClientNamespace is the namespace for the metrics

Variables

View Source
var (
	// PendingTxsPerChain is a gauge that contains the number of pending transactions per chain
	PendingTxsPerChain = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: ZetaClientNamespace,
		Name:      "pending_txs_total",
		Help:      "Number of pending transactions per chain",
	}, []string{"chain"})

	// GetFilterLogsPerChain is a counter that contains the number of getLogs per chain
	GetFilterLogsPerChain = promauto.NewCounterVec(prometheus.CounterOpts{
		Namespace: ZetaClientNamespace,
		Name:      "rpc_getFilterLogs_count",
		Help:      "Count of getLogs per chain",
	}, []string{"chain"})

	// GetBlockByNumberPerChain is a counter that contains the number of getBlockByNumber per chain
	GetBlockByNumberPerChain = promauto.NewCounterVec(prometheus.CounterOpts{
		Namespace: ZetaClientNamespace,
		Name:      "rpc_getBlockByNumber_count",
		Help:      "Count of getLogs per chain",
	}, []string{"chain"})

	// TSSNodeBlamePerPubKey is a counter that contains the number of tss node blame per pubkey
	TSSNodeBlamePerPubKey = promauto.NewCounterVec(prometheus.CounterOpts{
		Namespace: ZetaClientNamespace,
		Name:      "tss_node_blame_count",
		Help:      "TSS node blame counter per pubkey",
	}, []string{"pubkey"})

	// RelayerKeyBalance is a gauge that contains the relayer key balance of the chain
	RelayerKeyBalance = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: ZetaClientNamespace,
		Name:      "relayer_key_balance",
		Help:      "Relayer key balance of the chain",
	}, []string{"chain"})

	// HotKeyBurnRate is a gauge that contains the fee burn rate of the hotkey
	HotKeyBurnRate = promauto.NewGauge(prometheus.GaugeOpts{
		Namespace: ZetaClientNamespace,
		Name:      "hotkey_burn_rate",
		Help:      "Fee burn rate of the hotkey",
	})

	// NumberOfUTXO is a gauge that contains the number of UTXOs
	NumberOfUTXO = promauto.NewGauge(prometheus.GaugeOpts{
		Namespace: ZetaClientNamespace,
		Name:      "utxo_number",
		Help:      "Number of UTXOs",
	})

	// LastScannedBlockNumber is a gauge that contains the last scanned block number per chain
	LastScannedBlockNumber = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: ZetaClientNamespace,
		Name:      "last_scanned_block_number",
		Help:      "Last scanned block number per chain",
	}, []string{"chain"})

	// LastCoreBlockNumber is a gauge that contains the last core block number
	LastCoreBlockNumber = promauto.NewGauge(prometheus.GaugeOpts{
		Namespace: ZetaClientNamespace,
		Name:      "last_core_block_number",
		Help:      "Last core block number",
	})

	// Info is a gauge that contains information about the zetaclient environment
	Info = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: ZetaClientNamespace,
		Name:      "info",
		Help:      "Information about Zetaclient environment",
	}, []string{"version"})

	// LastStartTime is a gauge that contains the start time in Unix time
	LastStartTime = promauto.NewGauge(prometheus.GaugeOpts{
		Namespace: ZetaClientNamespace,
		Name:      "last_start_timestamp_seconds",
		Help:      "Start time in Unix time",
	})

	// NumActiveMsgSigns is a gauge that contains the number of concurrent key signs
	NumActiveMsgSigns = promauto.NewGauge(prometheus.GaugeOpts{
		Namespace: ZetaClientNamespace,
		Name:      "num_active_message_signs",
		Help:      "Number of concurrent key signs",
	})

	// PercentageOfRateReached is a gauge that contains the percentage of the rate limiter rate reached
	PercentageOfRateReached = promauto.NewGauge(prometheus.GaugeOpts{
		Namespace: ZetaClientNamespace,
		Name:      "percentage_of_rate_reached",
		Help:      "Percentage of the rate limiter rate reached",
	})

	// SignLatency is a histogram of of the TSS keysign latency
	SignLatency = promauto.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: ZetaClientNamespace,
		Name:      "sign_latency",
		Help:      "Histogram of the TSS keysign latency",
		Buckets:   []float64{1, 7, 15, 30, 60, 120, 240},
	}, []string{"result"})

	// RPCInProgress is a gauge that contains the number of RPCs requests in progress
	RPCInProgress = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: ZetaClientNamespace,
		Name:      "rpc_in_progress",
		Help:      "Number of RPC requests in progress",
	}, []string{"host"})

	// RPCCount is a counter that contains the number of total RPC requests
	RPCCount = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ZetaClientNamespace,
			Name:      "rpc_count",
			Help:      "A counter for number of total RPC requests",
		},
		[]string{"host", "code"},
	)

	// RPCLatency is a histogram of the RPC latency
	RPCLatency = promauto.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: ZetaClientNamespace,
			Name:      "rpc_duration_seconds",
			Help:      "A histogram of the RPC duration in seconds",
			Buckets:   prometheus.DefBuckets,
		},
		[]string{"host"},
	)

	NumConnectedPeers = promauto.NewGauge(prometheus.GaugeOpts{
		Namespace: ZetaClientNamespace,
		Name:      "num_connected_peers",
		Help:      "The number of connected peers (authenticated keygen peers)",
	})
)

Functions

func GetInstrumentedHTTPClient

func GetInstrumentedHTTPClient(endpoint string) (*http.Client, error)

GetInstrumentedHTTPClient sets up a http client that emits prometheus metrics

Types

type BurnRate

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

BurnRate calculates the average burn rate for a range of blocks.

func NewBurnRate

func NewBurnRate(windowSize int64) *BurnRate

NewBurnRate creates a new BurnRate instance with a window size.

func (*BurnRate) AddFee

func (br *BurnRate) AddFee(amount int64, block int64) error

AddFee adds fee amount spent on a tx for a particular block. It is added to a queue which is used to calculate the average burn rate for a range of blocks determined by the window size.

func (*BurnRate) GetBurnRate

func (br *BurnRate) GetBurnRate() sdkmath.Int

GetBurnRate calculates current burn rate and return the value.

type Metrics

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

Metrics is a struct that contains the http server for metrics

func NewMetrics

func NewMetrics() (*Metrics, error)

NewMetrics creates a new Metrics instance

func (*Metrics) Start

func (m *Metrics) Start()

Start starts the metrics server

func (*Metrics) Stop

func (m *Metrics) Stop() error

Stop stops the metrics server

type TelemetryServer

type TelemetryServer struct {
	HotKeyBurnRate *BurnRate
	// contains filtered or unexported fields
}

TelemetryServer provides http endpoint for Tss server

func NewTelemetryServer

func NewTelemetryServer() *TelemetryServer

NewTelemetryServer should only listen to the loopback

func (*TelemetryServer) AddFeeEntry

func (t *TelemetryServer) AddFeeEntry(block int64, amount int64)

AddFeeEntry adds fee entry

func (*TelemetryServer) GetConnectedPeers

func (t *TelemetryServer) GetConnectedPeers() []peer.AddrInfo

func (*TelemetryServer) GetCoreBlockNumber

func (t *TelemetryServer) GetCoreBlockNumber() int64

GetCoreBlockNumber returns core block number

func (*TelemetryServer) GetIPAddress

func (t *TelemetryServer) GetIPAddress() string

GetIPAddress gets p2pid

func (*TelemetryServer) GetKnownPeers

func (t *TelemetryServer) GetKnownPeers() []peer.AddrInfo

func (*TelemetryServer) GetLastScannedBlockNumber

func (t *TelemetryServer) GetLastScannedBlockNumber(chainID int64) uint64

GetLastScannedBlockNumber returns last scanned block number for chain

func (*TelemetryServer) GetLastStartTimestamp

func (t *TelemetryServer) GetLastStartTimestamp() time.Time

GetLastStartTimestamp returns last start timestamp

func (*TelemetryServer) GetP2PID

func (t *TelemetryServer) GetP2PID() string

GetP2PID gets p2pid

func (*TelemetryServer) GetPingRTT

func (t *TelemetryServer) GetPingRTT() map[peer.ID]int64

func (*TelemetryServer) Handlers

func (t *TelemetryServer) Handlers() http.Handler

Handlers registers the API routes and returns a new HTTP handler

func (*TelemetryServer) SetConnectedPeers

func (t *TelemetryServer) SetConnectedPeers(peers []peer.AddrInfo)

func (*TelemetryServer) SetCoreBlockNumber

func (t *TelemetryServer) SetCoreBlockNumber(blockNumber int64)

SetCoreBlockNumber sets core block number in telemetry and metrics

func (*TelemetryServer) SetIPAddress

func (t *TelemetryServer) SetIPAddress(ip string)

SetIPAddress sets p2pid

func (*TelemetryServer) SetKnownPeers

func (t *TelemetryServer) SetKnownPeers(peers []peer.AddrInfo)

func (*TelemetryServer) SetLastScannedBlockNumber

func (t *TelemetryServer) SetLastScannedBlockNumber(chain chains.Chain, blockNumber uint64)

SetLastScannedBlockNumber last scanned block number for chain in telemetry and metrics

func (*TelemetryServer) SetNumberOfUTXOs

func (t *TelemetryServer) SetNumberOfUTXOs(numberOfUTXOs int)

SetNumberOfUTXOs sets number of UTXOs in telemetry and metrics

func (*TelemetryServer) SetP2PID

func (t *TelemetryServer) SetP2PID(p2pid string)

SetP2PID sets p2pid

func (*TelemetryServer) SetPingRTT

func (t *TelemetryServer) SetPingRTT(rtt map[peer.ID]int64)

func (*TelemetryServer) Start

func (t *TelemetryServer) Start() error

Start starts telemetry server

func (*TelemetryServer) Stop

func (t *TelemetryServer) Stop() error

Stop stops telemetry server

Jump to

Keyboard shortcuts

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