Help us shape the future of Go! Take the 2026 Go Developer Survey

metrics

package
v0.1.113 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseFeeMetric

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

BaseFeeMetric calculates average base fees over block-count windows

func NewBaseFeeMetric

func NewBaseFeeMetric() *BaseFeeMetric

NewBaseFeeMetric creates a new base fee calculator

func (*BaseFeeMetric) GetMetric

func (b *BaseFeeMetric) GetMetric() any

GetMetric returns the current base fee statistics

func (*BaseFeeMetric) GetUpdateInterval

func (b *BaseFeeMetric) GetUpdateInterval() time.Duration

GetUpdateInterval returns how often this metric should be updated

func (*BaseFeeMetric) Name

func (b *BaseFeeMetric) Name() string

Name returns the metric identifier

func (*BaseFeeMetric) ProcessBlock

func (b *BaseFeeMetric) ProcessBlock(block rpctypes.PolyBlock)

ProcessBlock adds a new block to calculate base fee metrics

type BaseFeeStats

type BaseFeeStats struct {
	BaseFee10       *big.Int // Average base fee (10 blocks)
	BaseFee30       *big.Int // Average base fee (30 blocks)
	BlocksAvailable int      // Number of blocks available for calculation
}

BaseFeeStats provides detailed base fee statistics

type BlockTimeMetric

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

BlockTimeMetric calculates average block time over a rolling window

func NewBlockTimeMetric

func NewBlockTimeMetric() *BlockTimeMetric

NewBlockTimeMetric creates a new block time calculator

func (*BlockTimeMetric) GetMetric

func (b *BlockTimeMetric) GetMetric() any

GetMetric returns the current block time statistics

func (*BlockTimeMetric) GetUpdateInterval

func (b *BlockTimeMetric) GetUpdateInterval() time.Duration

GetUpdateInterval returns how often this metric should be updated

func (*BlockTimeMetric) Name

func (b *BlockTimeMetric) Name() string

Name returns the metric identifier

func (*BlockTimeMetric) ProcessBlock

func (b *BlockTimeMetric) ProcessBlock(block rpctypes.PolyBlock)

ProcessBlock adds a new block to calculate block time

type BlockTimeStats

type BlockTimeStats struct {
	AverageBlockTime time.Duration // Average time between blocks
	MinBlockTime     time.Duration // Shortest block time in window
	MaxBlockTime     time.Duration // Longest block time in window
	WindowSize       int           // Current number of blocks tracked
	MaxWindowSize    int           // Maximum window size
}

BlockTimeStats provides detailed block time statistics

type EmptyBlockMetric

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

EmptyBlockMetric tracks the rate of empty blocks

func NewEmptyBlockMetric

func NewEmptyBlockMetric() *EmptyBlockMetric

NewEmptyBlockMetric creates a new empty block rate calculator

func (*EmptyBlockMetric) GetMetric

func (e *EmptyBlockMetric) GetMetric() any

GetMetric returns the current empty block statistics

func (*EmptyBlockMetric) GetUpdateInterval

func (e *EmptyBlockMetric) GetUpdateInterval() time.Duration

GetUpdateInterval returns how often this metric should be updated

func (*EmptyBlockMetric) Name

func (e *EmptyBlockMetric) Name() string

Name returns the metric identifier

func (*EmptyBlockMetric) ProcessBlock

func (e *EmptyBlockMetric) ProcessBlock(block rpctypes.PolyBlock)

ProcessBlock processes a new block to update empty block statistics

type EmptyBlockStats

type EmptyBlockStats struct {
	TotalBlocks      int     // Total blocks observed
	EmptyBlocks      int     // Total empty blocks
	OverallRate      float64 // Empty blocks / total blocks (all time)
	RecentRate       float64 // Empty blocks / total blocks (recent window)
	RecentWindowSize int     // Number of blocks in recent window
}

EmptyBlockStats provides detailed empty block statistics

type MetricPlugin

type MetricPlugin interface {
	// Name returns the unique identifier for this metric
	Name() string

	// ProcessBlock processes a new block for metric calculation
	ProcessBlock(block rpctypes.PolyBlock)

	// GetMetric returns the current calculated metric value
	GetMetric() any

	// GetUpdateInterval returns how often this metric should be recalculated
	GetUpdateInterval() time.Duration
}

MetricPlugin defines the interface for all metric calculators

type MetricUpdate

type MetricUpdate struct {
	Name  string
	Value any
	Time  time.Time
}

MetricUpdate represents an update from a metric plugin

type MetricsSystem

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

MetricsSystem manages all metric plugins and coordinates updates

func NewMetricsSystem

func NewMetricsSystem() *MetricsSystem

NewMetricsSystem creates a new metrics system

func (*MetricsSystem) GetMetric

func (m *MetricsSystem) GetMetric(name string) (any, bool)

GetMetric returns the current value of a specific metric

func (*MetricsSystem) GetUpdateChannel

func (m *MetricsSystem) GetUpdateChannel() <-chan MetricUpdate

GetUpdateChannel returns the channel for metric updates

func (*MetricsSystem) ProcessBlock

func (m *MetricsSystem) ProcessBlock(block rpctypes.PolyBlock)

ProcessBlock sends a new block to all registered plugins

func (*MetricsSystem) RegisterPlugin

func (m *MetricsSystem) RegisterPlugin(plugin MetricPlugin)

RegisterPlugin registers a new metric plugin

func (*MetricsSystem) Stop

func (m *MetricsSystem) Stop()

Stop gracefully shuts down the metrics system

type TPSMetric

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

TPSMetric calculates transactions per second over a rolling window

func NewTPSMetric

func NewTPSMetric() *TPSMetric

NewTPSMetric creates a new TPS calculator with a 30-second window

func (*TPSMetric) GetMetric

func (t *TPSMetric) GetMetric() any

GetMetric returns the current TPS value

func (*TPSMetric) GetUpdateInterval

func (t *TPSMetric) GetUpdateInterval() time.Duration

GetUpdateInterval returns how often this metric should be updated

func (*TPSMetric) Name

func (t *TPSMetric) Name() string

Name returns the metric identifier

func (*TPSMetric) ProcessBlock

func (t *TPSMetric) ProcessBlock(block rpctypes.PolyBlock)

ProcessBlock adds a new block to the calculation window

type TPSStats

type TPSStats struct {
	CurrentTPS   float64
	WindowSize   time.Duration
	BlockCount   int
	TotalTxCount int
}

TPSStats provides detailed TPS statistics

type ThroughputMetric

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

ThroughputMetric calculates throughput metrics over block-count windows

func NewThroughputMetric

func NewThroughputMetric() *ThroughputMetric

NewThroughputMetric creates a new throughput calculator

func (*ThroughputMetric) GetMetric

func (t *ThroughputMetric) GetMetric() any

GetMetric returns the current throughput statistics

func (*ThroughputMetric) GetUpdateInterval

func (t *ThroughputMetric) GetUpdateInterval() time.Duration

GetUpdateInterval returns how often this metric should be updated

func (*ThroughputMetric) Name

func (t *ThroughputMetric) Name() string

Name returns the metric identifier

func (*ThroughputMetric) ProcessBlock

func (t *ThroughputMetric) ProcessBlock(block rpctypes.PolyBlock)

ProcessBlock adds a new block to calculate throughput metrics

type ThroughputStats

type ThroughputStats struct {
	TPS10           float64 // Transactions per second (10 blocks)
	TPS30           float64 // Transactions per second (30 blocks)
	GPS10           float64 // Gas per second (10 blocks)
	GPS30           float64 // Gas per second (30 blocks)
	BlocksAvailable int     // Number of blocks available for calculation
}

ThroughputStats provides detailed throughput statistics

Jump to

Keyboard shortcuts

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