metrics

package
v0.0.0-...-eb934a0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnabledFlagName    = "metrics.enabled"
	ListenAddrFlagName = "metrics.addr"
	PortFlagName       = "metrics.port"
)

Variables

View Source
var NoopHTTPRecorder = new(noopHTTPRecorder)
View Source
var NoopNodeRecorder = new(noopNodeRecorder)

Functions

func CLIFlags

func CLIFlags(envPrefix string) []cli.Flag

func LaunchBalanceMetrics

func LaunchBalanceMetrics(ctx context.Context, log log.Logger, r *prometheus.Registry, ns string, client *ethclient.Client, account common.Address)

LaunchBalanceMetrics fires off a go rountine that queries the balance of the supplied account & periodically records it to the balance metric of the namespace. The balance of the account is recorded in Ether (not Wei). Cancel the supplied context to shut down the go routine

func ListenAndServe

func ListenAndServe(ctx context.Context, r *prometheus.Registry, hostname string, port int) error

func NewHTTPRecordingMiddleware

func NewHTTPRecordingMiddleware(rec HTTPRecorder, next http.Handler) http.Handler

func NewRegistry

func NewRegistry() *prometheus.Registry

Types

type CLIConfig

type CLIConfig struct {
	Enabled    bool
	ListenAddr string
	ListenPort int
}

func ReadCLIConfig

func ReadCLIConfig(ctx *cli.Context) CLIConfig

func (CLIConfig) Check

func (m CLIConfig) Check() error

type DocumentedMetric

type DocumentedMetric struct {
	Type   string   `json:"type"`
	Name   string   `json:"name"`
	Help   string   `json:"help"`
	Labels []string `json:"labels"`
}

type Event

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

func NewEvent

func NewEvent(factory Factory, ns string, subsystem string, name string, displayName string) Event

func (*Event) Record

func (e *Event) Record()

type EventVec

type EventVec struct {
	Total    prometheus.CounterVec
	LastTime prometheus.GaugeVec
}

func NewEventVec

func NewEventVec(factory Factory, ns string, subsystem string, name string, displayName string, labelNames []string) EventVec

func (*EventVec) Record

func (e *EventVec) Record(lvs ...string)

type Factory

type Factory interface {
	NewCounter(opts prometheus.CounterOpts) prometheus.Counter
	NewCounterVec(opts prometheus.CounterOpts, labelNames []string) *prometheus.CounterVec
	NewGauge(opts prometheus.GaugeOpts) prometheus.Gauge
	NewGaugeVec(opts prometheus.GaugeOpts, labelNames []string) *prometheus.GaugeVec
	NewHistogram(opts prometheus.HistogramOpts) prometheus.Histogram
	NewHistogramVec(opts prometheus.HistogramOpts, labelNames []string) *prometheus.HistogramVec
	NewSummary(opts prometheus.SummaryOpts) prometheus.Summary
	NewSummaryVec(opts prometheus.SummaryOpts, labelNames []string) *prometheus.SummaryVec
	Document() []DocumentedMetric
}

func With

func With(registry *prometheus.Registry) Factory

type HTTPParams

type HTTPParams struct {
	Method     string
	StatusCode int
}

type HTTPRecorder

type HTTPRecorder interface {
	RecordHTTPRequestDuration(params *HTTPParams, dur time.Duration)
	RecordHTTPResponseSize(params *HTTPParams, size int)
	RecordInflightRequest(params *HTTPParams, quantity int)
	RecordHTTPRequest(params *HTTPParams)
	RecordHTTPResponse(params *HTTPParams)
}

func NewPromHTTPRecorder

func NewPromHTTPRecorder(r *prometheus.Registry, ns string) HTTPRecorder

type NodeRecorder

type NodeRecorder interface {
	RecordUp()
	RecordInfo(version string)
}

func NewPromNodeRecorder

func NewPromNodeRecorder(r *prometheus.Registry, ns string) NodeRecorder

type NoopRefMetrics

type NoopRefMetrics struct{}

NoopRefMetrics can be embedded in a noop version of a metric implementation to have a noop RefMetricer.

func (*NoopRefMetrics) RecordL1Ref

func (*NoopRefMetrics) RecordL1Ref(string, eth.L1BlockRef)

func (*NoopRefMetrics) RecordL2Ref

func (*NoopRefMetrics) RecordL2Ref(string, eth.L2BlockRef)

func (*NoopRefMetrics) RecordRef

type PromHTTPRecorder

type PromHTTPRecorder struct {
	HTTPRequestDuration  *prometheus.HistogramVec
	HTTPResponseSize     *prometheus.HistogramVec
	HTTPInflightRequests *prometheus.GaugeVec
	HTTPRequests         *prometheus.CounterVec
	HTTPResponses        *prometheus.CounterVec
}

func (*PromHTTPRecorder) RecordHTTPRequest

func (p *PromHTTPRecorder) RecordHTTPRequest(params *HTTPParams)

func (*PromHTTPRecorder) RecordHTTPRequestDuration

func (p *PromHTTPRecorder) RecordHTTPRequestDuration(params *HTTPParams, dur time.Duration)

func (*PromHTTPRecorder) RecordHTTPResponse

func (p *PromHTTPRecorder) RecordHTTPResponse(params *HTTPParams)

func (*PromHTTPRecorder) RecordHTTPResponseSize

func (p *PromHTTPRecorder) RecordHTTPResponseSize(params *HTTPParams, size int)

func (*PromHTTPRecorder) RecordInflightRequest

func (p *PromHTTPRecorder) RecordInflightRequest(params *HTTPParams, quantity int)

type PromNodeRecorder

type PromNodeRecorder struct {
	Up   prometheus.Gauge
	Info *prometheus.GaugeVec
}

func (*PromNodeRecorder) RecordInfo

func (p *PromNodeRecorder) RecordInfo(version string)

func (*PromNodeRecorder) RecordUp

func (p *PromNodeRecorder) RecordUp()

type RefMetricer

type RefMetricer interface {
	RecordRef(layer string, name string, num uint64, timestamp uint64, h common.Hash)
	RecordL1Ref(name string, ref eth.L1BlockRef)
	RecordL2Ref(name string, ref eth.L2BlockRef)
}

type RefMetrics

type RefMetrics struct {
	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
}

RefMetrics provides block reference metrics. It's a metrics module that's supposed to be embedded into a service metrics type. The service metrics type should set the full namespace and create the factory before calling NewRefMetrics.

func MakeRefMetrics

func MakeRefMetrics(ns string, factory Factory) RefMetrics

MakeRefMetrics returns a new RefMetrics, initializing its prometheus fields using factory. It is supposed to be used inside the construtors of metrics structs for any op service after the full namespace and factory have been setup.

ns is the fully qualified namespace, e.g. "op_node_default".

func (*RefMetrics) RecordL1Ref

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

func (*RefMetrics) RecordL2Ref

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

func (*RefMetrics) RecordRef

func (m *RefMetrics) RecordRef(layer string, name string, num uint64, timestamp uint64, h common.Hash)

Jump to

Keyboard shortcuts

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