metrics

package
v1.1.5-mainnet-patch-1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InfuraRegistry = metrics.DefaultRegistry

Note, must use metrics.DefaultRegistry from geth, since go-rpc-provider depends on it for rpc metrics by default. When RPC middleware supported at server side, we can use a custom metrics registry.

Functions

func GetOrRegisterCounter

func GetOrRegisterCounter(nameFormat string, nameArgs ...interface{}) metrics.Counter

func GetOrRegisterGauge

func GetOrRegisterGauge(nameFormat string, nameArgs ...interface{}) metrics.Gauge

func GetOrRegisterGaugeFloat64

func GetOrRegisterGaugeFloat64(nameFormat string, nameArgs ...interface{}) metrics.GaugeFloat64

func GetOrRegisterHistogram

func GetOrRegisterHistogram(nameFormat string, nameArgs ...interface{}) metrics.Histogram

func GetOrRegisterMeter

func GetOrRegisterMeter(nameFormat string, nameArgs ...interface{}) metrics.Meter

func GetOrRegisterTimer

func GetOrRegisterTimer(nameFormat string, nameArgs ...interface{}) metrics.Timer

func Init

func Init()

This package should be imported before any metric (e.g. timer, histogram) created. Because, `metrics.Enabled` in go-ethereum is `false` by default, which leads to noop metric created for static variables in any package.

In addition, this package should be imported after the initialization of viper and logrus.

func NewHistogram

func NewHistogram() metrics.Histogram

func UpdateCfxRpcLogFilter

func UpdateCfxRpcLogFilter(method string, cfx sdk.ClientOperator, filter *types.LogFilter)

func UpdateEthRpcLogFilter

func UpdateEthRpcLogFilter(method string, eth *client.RpcEthClient, filter *w3types.FilterQuery)

Types

type InputBlockMetric

type InputBlockMetric struct{}

InputBlockMetric is used to add metrics for input block parameter.

func (*InputBlockMetric) Update1

func (metric *InputBlockMetric) Update1(blockNum *types.BlockNumber, method string, eth *client.RpcEthClient)

func (*InputBlockMetric) Update2

func (metric *InputBlockMetric) Update2(blockNumOrHash *types.BlockNumberOrHash, method string, eth *client.RpcEthClient)

type InputEpochMetric

type InputEpochMetric struct{}

InputEpochMetric is used to add metrics for input epoch parameter.

func (*InputEpochMetric) Update

func (metric *InputEpochMetric) Update(epoch *types.Epoch, method string, cfx sdk.ClientOperator)

Update marks the percentage for different epochs. If epoch number specified, add statistic for epoch gap against latest mined.

func (*InputEpochMetric) Update2

func (metric *InputEpochMetric) Update2(ebh *types.EpochOrBlockHash, method string, cfx sdk.ClientOperator)

type Metrics

type Metrics struct {
	RPC           RpcMetrics
	PubSub        PubSubMetrics
	Sync          SyncMetrics
	Store         StoreMetrics
	Nodes         NodeManagerMetrics
	VirtualFilter VirtualFilterMetrics
}
var Registry Metrics

type NodeManagerMetrics

type NodeManagerMetrics struct{}

Node manager metrics

func (*NodeManagerMetrics) NodeAvailability

func (*NodeManagerMetrics) NodeAvailability(space, group, node string) string

func (*NodeManagerMetrics) NodeLatency

func (*NodeManagerMetrics) NodeLatency(space, group, node string) string

func (*NodeManagerMetrics) Routes

func (*NodeManagerMetrics) Routes(space, group, node string) metrics.Meter

type Percentage

type Percentage interface {
	Mark(marked bool)
	Value() float64 // e.g. 99.38 means 99.38%
}

Percentage implements the GaugeFloat64 interface for percentage statistic.

func GetOrRegisterPercentage

func GetOrRegisterPercentage(name string, args ...interface{}) Percentage

GetOrRegisterPercentage returns an existing Percentage or constructs and registers a new standard Percentage.

func GetOrRegisterTimeWindowPercentage

func GetOrRegisterTimeWindowPercentage(
	slotInterval time.Duration, numSlots int, name string, args ...interface{},
) Percentage

GetOrRegisterTimeWindowPercentage returns an existing Percentage or constructs and registers a new time window Percentage.

func GetOrRegisterTimeWindowPercentageDefault

func GetOrRegisterTimeWindowPercentageDefault(name string, args ...interface{}) Percentage

GetOrRegisterTimeWindowPercentageDefault returns an existing Percentage or constructs and registers a new time window Percentage.

func NewPercentage

func NewPercentage() Percentage

NewPercentage constructs a new standard percentage metric.

func NewTimeWindowPercentage

func NewTimeWindowPercentage(slotInterval time.Duration, numSlots int) Percentage

NewTimeWindowPercentage constructs a new time window Percentage.

type PubSubMetrics

type PubSubMetrics struct{}

PubSub metrics

func (*PubSubMetrics) InputLogFilter

func (*PubSubMetrics) InputLogFilter(space string) Percentage

func (*PubSubMetrics) Sessions

func (*PubSubMetrics) Sessions(space, topic, node string) metrics.Gauge

type RpcMetrics

type RpcMetrics struct{}

RPC metrics

func (*RpcMetrics) BatchLatency

func (*RpcMetrics) BatchLatency() metrics.Histogram

func (*RpcMetrics) BatchSize

func (*RpcMetrics) BatchSize() metrics.Histogram

func (*RpcMetrics) FullnodeErrorRate

func (*RpcMetrics) FullnodeErrorRate(node ...string) Percentage

func (*RpcMetrics) FullnodeNonRpcErrorRate

func (*RpcMetrics) FullnodeNonRpcErrorRate(node ...string) Percentage

func (*RpcMetrics) FullnodeQps

func (*RpcMetrics) FullnodeQps(node, space, method string, err error) metrics.Timer

func (*RpcMetrics) InputBlock

func (*RpcMetrics) InputBlock(method, block string) Percentage

func (*RpcMetrics) InputBlockGap

func (*RpcMetrics) InputBlockGap(method string) metrics.Histogram

func (*RpcMetrics) InputBlockHash

func (*RpcMetrics) InputBlockHash(method string) Percentage

func (*RpcMetrics) InputEpoch

func (*RpcMetrics) InputEpoch(method, epoch string) Percentage

func (*RpcMetrics) InputEpochGap

func (*RpcMetrics) InputEpochGap(method string) metrics.Histogram

func (*RpcMetrics) Percentage

func (*RpcMetrics) Percentage(method, name string) Percentage

func (*RpcMetrics) StoreHit

func (*RpcMetrics) StoreHit(method, storeName string) Percentage

func (*RpcMetrics) UpdateDuration

func (*RpcMetrics) UpdateDuration(method string, err error, start time.Time)

type SlotData

type SlotData interface {
	Add(SlotData) SlotData // accumulate
	Sub(SlotData) SlotData // dissipate
	SnapShot() SlotData    // snapshot copy
}

SlotData aggregatable slot data for time window

type StoreMetrics

type StoreMetrics struct{}

Store metrics

func (*StoreMetrics) GetLogs

func (*StoreMetrics) GetLogs() TimerUpdater

func (*StoreMetrics) Pop

func (*StoreMetrics) Pop(storeName string) TimerUpdater

func (*StoreMetrics) Push

func (*StoreMetrics) Push(storeName string) TimerUpdater

type SyncMetrics

type SyncMetrics struct{}

Sync service metrics

func (*SyncMetrics) QueryEpochData

func (*SyncMetrics) QueryEpochData(space string) TimerUpdater

func (*SyncMetrics) QueryEpochDataAvailability

func (*SyncMetrics) QueryEpochDataAvailability(space string) Percentage

func (*SyncMetrics) SyncOnceQps

func (*SyncMetrics) SyncOnceQps(space, storeName string, err error) metrics.Timer

func (*SyncMetrics) SyncOnceSize

func (*SyncMetrics) SyncOnceSize(space, storeName string) metrics.Histogram

type TimeWindow

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

TimeWindow slices time window into slots and maintains slot expiry and creation

func NewTimeWindow

func NewTimeWindow(slotInterval time.Duration, numSlots int) *TimeWindow

func (*TimeWindow) Add

func (tw *TimeWindow) Add(sample SlotData)

Add adds data sample to time window

func (*TimeWindow) Data

func (tw *TimeWindow) Data() SlotData

Data returns the aggregation data within the time window scope

type TimerUpdater

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

TimerUpdater is used to update timer metric with native defer syntax.

func NewTimerUpdater

func NewTimerUpdater(timer metrics.Timer) TimerUpdater

NewTimerUpdater creates an instance to update timer metric.

func NewTimerUpdaterByName

func NewTimerUpdaterByName(name string) TimerUpdater

NewTimerUpdaterByName creates an instance to update timer metric of specified name.

func (*TimerUpdater) Update

func (updater *TimerUpdater) Update()

Update updates the underlying timer metric.

func (*TimerUpdater) UpdateDuration

func (updater *TimerUpdater) UpdateDuration(duration time.Duration)

Update updates the underlying timer metric with duration.

type TrafficCollector

type TrafficCollector interface {
	MarkHit(source string)
	TopkVisitors(k int) []Visitor
}

TrafficCollector collects traffic hits and calculate topK stats.

func DefaultTrafficCollector

func DefaultTrafficCollector() TrafficCollector

type VirtualFilterMetrics

type VirtualFilterMetrics struct{}

Virtual filter metrics

func (*VirtualFilterMetrics) PersistFilterChanges

func (*VirtualFilterMetrics) PersistFilterChanges(space, node, store string) TimerUpdater

func (*VirtualFilterMetrics) PollOnceQps

func (*VirtualFilterMetrics) PollOnceQps(space, node string, err error) metrics.Timer

func (*VirtualFilterMetrics) PollOnceSize

func (*VirtualFilterMetrics) PollOnceSize(space, node string) metrics.Histogram

func (*VirtualFilterMetrics) QueryFilterChanges

func (*VirtualFilterMetrics) QueryFilterChanges(space, node, store string) TimerUpdater

func (*VirtualFilterMetrics) Sessions

func (*VirtualFilterMetrics) Sessions(space string, filterType, node string) metrics.Gauge

func (*VirtualFilterMetrics) StoreQueryPercentage

func (*VirtualFilterMetrics) StoreQueryPercentage(space string, node, store string) Percentage

type Visitor

type Visitor struct {
	Source string // visitor source
	Hits   int    // visitor hit count
}

Visitor visitor traffic such as vistor source and hit count

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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