metrics

package
v1.0.1-rc.4 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT, MIT Imports: 19 Imported by: 0

Documentation

Overview

Package metrics provides a set of metrics for the kroma-node.

Index

Constants

View Source
const (
	Namespace = "kroma_node"

	RPCServerSubsystem = "rpc_server"
	RPCClientSubsystem = "rpc_client"

	BatchMethod = "<batch>"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheMetrics

type CacheMetrics struct {
	SizeVec *prometheus.GaugeVec
	GetVec  *prometheus.CounterVec
	AddVec  *prometheus.CounterVec
}

CacheMetrics implements the Metrics interface in the caching package, implementing reusable metrics for different caches.

func NewCacheMetrics

func NewCacheMetrics(factory metrics.Factory, ns string, name string, displayName string) *CacheMetrics

func (*CacheMetrics) CacheAdd

func (m *CacheMetrics) CacheAdd(typeLabel string, typeCacheSize int, evicted bool)

CacheAdd meters the addition of an item with a given type to the cache, metering the change of the cache size of that type, and indicating a corresponding eviction if any.

func (*CacheMetrics) CacheGet

func (m *CacheMetrics) CacheGet(typeLabel string, hit bool)

CacheGet meters a lookup of an item with a given type to the cache and indicating if the lookup was a hit.

type EventMetrics

type EventMetrics struct {
	Total    prometheus.Counter
	LastTime prometheus.Gauge
}

func NewEventMetrics

func NewEventMetrics(factory metrics.Factory, ns string, name string, displayName string) *EventMetrics

func (*EventMetrics) RecordEvent

func (e *EventMetrics) RecordEvent()

type Metricer

type Metricer interface {
	RecordInfo(version string)
	RecordUp()
	RecordRPCServerRequest(method string) func()
	RecordRPCClientRequest(method string) func(err error)
	RecordRPCClientResponse(method string, err error)
	SetDerivationIdle(status bool)
	RecordPipelineReset()
	RecordSequencingError()
	RecordPublishingError()
	RecordDerivationError()
	RecordReceivedUnsafePayload(payload *eth.ExecutionPayload)

	RecordL1Ref(name string, ref eth.L1BlockRef)
	RecordL2Ref(name string, ref eth.L2BlockRef)
	RecordUnsafePayloadsBuffer(length uint64, memSize uint64, next eth.BlockID)
	CountSequencedTxs(count int)
	RecordL1ReorgDepth(d uint64)
	RecordProposerInconsistentL1Origin(from eth.BlockID, to eth.BlockID)
	RecordProposerReset()
	RecordGossipEvent(evType int32)
	IncPeerCount()
	DecPeerCount()
	IncStreamCount()
	DecStreamCount()
	RecordBandwidth(ctx context.Context, bwc *libp2pmetrics.BandwidthCounter)
	RecordProposerBuildingDiffTime(duration time.Duration)
	RecordProposerSealingTime(duration time.Duration)
	Document() []metrics.DocumentedMetric
	RecordChannelInputBytes(num int)
	// P2P Metrics
	SetPeerScores(allScores []store.PeerScores)
	ClientPayloadByNumberEvent(num uint64, resultCode byte, duration time.Duration)
	ServerPayloadByNumberEvent(num uint64, resultCode byte, duration time.Duration)
	PayloadsQuarantineSize(n int)
	RecordPeerUnban()
	RecordIPUnban()
	RecordDial(allow bool)
	RecordAccept(allow bool)
	// contains filtered or unexported methods
}
var NoopMetrics Metricer = new(noopMetricer)

type Metrics

type Metrics struct {
	Info *prometheus.GaugeVec
	Up   prometheus.Gauge

	RPCServerRequestsTotal          *prometheus.CounterVec
	RPCServerRequestDurationSeconds *prometheus.HistogramVec
	RPCClientRequestsTotal          *prometheus.CounterVec
	RPCClientRequestDurationSeconds *prometheus.HistogramVec
	RPCClientResponsesTotal         *prometheus.CounterVec

	L1SourceCache *CacheMetrics
	L2SourceCache *CacheMetrics

	DerivationIdle prometheus.Gauge

	PipelineResets   *EventMetrics
	UnsafePayloads   *EventMetrics
	DerivationErrors *EventMetrics
	SequencingErrors *EventMetrics
	PublishingErrors *EventMetrics

	P2PReqDurationSeconds *prometheus.HistogramVec
	P2PReqTotal           *prometheus.CounterVec
	P2PPayloadByNumber    *prometheus.GaugeVec

	PayloadsQuarantineTotal prometheus.Gauge

	ProposerInconsistentL1Origin *EventMetrics
	ProposerResets               *EventMetrics

	L1RequestDurationSeconds *prometheus.HistogramVec

	ProposerBuildingDiffDurationSeconds prometheus.Histogram
	ProposerBuildingDiffTotal           prometheus.Counter

	ProposerSealingDurationSeconds prometheus.Histogram
	ProposerSealingTotal           prometheus.Counter

	UnsafePayloadsBufferLen     prometheus.Gauge
	UnsafePayloadsBufferMemSize prometheus.Gauge

	RefsNumber  *prometheus.GaugeVec
	RefsTime    *prometheus.GaugeVec
	RefsHash    *prometheus.GaugeVec
	RefsSeqNr   *prometheus.GaugeVec
	RefsLatency *prometheus.GaugeVec
	// hash of the last seen block per name, so we don't reduce/increase latency on updates of the same data,
	// and only count the first occurrence
	LatencySeen map[string]common.Hash

	L1ReorgDepth prometheus.Histogram

	TransactionsSequencedTotal prometheus.Counter

	// P2P Metrics
	PeerCount         prometheus.Gauge
	StreamCount       prometheus.Gauge
	GossipEventsTotal *prometheus.CounterVec
	BandwidthTotal    *prometheus.GaugeVec
	PeerUnbans        prometheus.Counter
	IPUnbans          prometheus.Counter
	Dials             *prometheus.CounterVec
	Accepts           *prometheus.CounterVec
	PeerScores        *prometheus.HistogramVec

	ChannelInputBytes prometheus.Counter
	// contains filtered or unexported fields
}

Metrics tracks all the metrics for the kroma-node.

func NewMetrics

func NewMetrics(procName string) *Metrics

NewMetrics creates a new Metrics instance with the given process name.

func (*Metrics) ClientPayloadByNumberEvent

func (m *Metrics) ClientPayloadByNumberEvent(num uint64, resultCode byte, duration time.Duration)

func (*Metrics) CountSequencedTxs

func (m *Metrics) CountSequencedTxs(count int)

func (*Metrics) DecPeerCount

func (m *Metrics) DecPeerCount()

func (*Metrics) DecStreamCount

func (m *Metrics) DecStreamCount()

func (*Metrics) Document

func (m *Metrics) Document() []metrics.DocumentedMetric

func (*Metrics) IncPeerCount

func (m *Metrics) IncPeerCount()

func (*Metrics) IncStreamCount

func (m *Metrics) IncStreamCount()

func (*Metrics) PayloadsQuarantineSize

func (m *Metrics) PayloadsQuarantineSize(n int)

func (*Metrics) RecordAccept added in v0.3.0

func (m *Metrics) RecordAccept(allow bool)

func (*Metrics) RecordBandwidth

func (m *Metrics) RecordBandwidth(ctx context.Context, bwc *libp2pmetrics.BandwidthCounter)

func (*Metrics) RecordChannelInputBytes

func (m *Metrics) RecordChannelInputBytes(inputCompressedBytes int)

func (*Metrics) RecordDerivationError

func (m *Metrics) RecordDerivationError()

func (*Metrics) RecordDial added in v0.3.0

func (m *Metrics) RecordDial(allow bool)

func (*Metrics) RecordGossipEvent

func (m *Metrics) RecordGossipEvent(evType int32)

func (*Metrics) RecordIPUnban added in v0.3.0

func (m *Metrics) RecordIPUnban()

func (*Metrics) RecordInfo

func (m *Metrics) RecordInfo(version string)

RecordInfo sets a pseudo-metric that contains versioning and config info for the kroma-node.

func (*Metrics) RecordL1Ref

func (m *Metrics) RecordL1Ref(name string, ref eth.L1BlockRef)

func (*Metrics) RecordL1ReorgDepth

func (m *Metrics) RecordL1ReorgDepth(d uint64)

func (*Metrics) RecordL1RequestTime added in v0.3.0

func (m *Metrics) RecordL1RequestTime(method string, duration time.Duration)

RecordL1RequestTime tracks the amount of time the derivation pipeline spent waiting for L1 data requests.

func (*Metrics) RecordL2Ref

func (m *Metrics) RecordL2Ref(name string, ref eth.L2BlockRef)

func (*Metrics) RecordPeerUnban added in v0.3.0

func (m *Metrics) RecordPeerUnban()

func (*Metrics) RecordPipelineReset

func (m *Metrics) RecordPipelineReset()

func (*Metrics) RecordProposerBuildingDiffTime

func (m *Metrics) RecordProposerBuildingDiffTime(duration time.Duration)

RecordProposerBuildingDiffTime tracks the amount of time the proposer was allowed between start to finish, incl. sealing, minus the block time. Ideally this is 0, realistically the proposer scheduler may be busy with other jobs like syncing sometimes.

func (*Metrics) RecordProposerInconsistentL1Origin

func (m *Metrics) RecordProposerInconsistentL1Origin(from eth.BlockID, to eth.BlockID)

func (*Metrics) RecordProposerReset

func (m *Metrics) RecordProposerReset()

func (*Metrics) RecordProposerSealingTime

func (m *Metrics) RecordProposerSealingTime(duration time.Duration)

RecordProposerSealingTime tracks the amount of time the proposer took to finish sealing the block. Ideally this is 0, realistically it may take some time.

func (*Metrics) RecordPublishingError

func (m *Metrics) RecordPublishingError()

func (*Metrics) RecordRPCClientRequest

func (m *Metrics) RecordRPCClientRequest(method string) func(err error)

RecordRPCClientRequest is a helper method to record an RPC client request. It bumps the requests metric, tracks the response duration, and records the response's error code.

func (*Metrics) RecordRPCClientResponse

func (m *Metrics) RecordRPCClientResponse(method string, err error)

RecordRPCClientResponse records an RPC response. It will convert the passed-in error into something metrics friendly. Nil errors get converted into <nil>, RPC errors are converted into rpc_<error code>, HTTP errors are converted into http_<status code>, and everything else is converted into <unknown>.

func (*Metrics) RecordRPCServerRequest

func (m *Metrics) RecordRPCServerRequest(method string) func()

RecordRPCServerRequest is a helper method to record an incoming RPC call to the kroma-node's RPC server. It bumps the requests metric, and tracks how long it takes to serve a response.

func (*Metrics) RecordReceivedUnsafePayload

func (m *Metrics) RecordReceivedUnsafePayload(payload *eth.ExecutionPayload)

func (*Metrics) RecordSequencingError

func (m *Metrics) RecordSequencingError()

func (*Metrics) RecordUnsafePayloadsBuffer

func (m *Metrics) RecordUnsafePayloadsBuffer(length uint64, memSize uint64, next eth.BlockID)

func (*Metrics) RecordUp

func (m *Metrics) RecordUp()

RecordUp sets the up metric to 1.

func (*Metrics) Serve

func (m *Metrics) Serve(ctx context.Context, hostname string, port int) error

Serve starts the metrics server on the given hostname and port. The server will be closed when the passed-in context is cancelled.

func (*Metrics) ServerPayloadByNumberEvent

func (m *Metrics) ServerPayloadByNumberEvent(num uint64, resultCode byte, duration time.Duration)

func (*Metrics) SetDerivationIdle

func (m *Metrics) SetDerivationIdle(status bool)

func (*Metrics) SetPeerScores

func (m *Metrics) SetPeerScores(allScores []store.PeerScores)

SetPeerScores updates the peer score metrics. Accepts a slice of peer scores in any order.

Jump to

Keyboard shortcuts

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