Documentation ¶
Index ¶
- Constants
- Variables
- func CLIFlags(envPrefix string) []cli.Flag
- func LaunchBalanceMetrics(log log.Logger, r *prometheus.Registry, ns string, client *ethclient.Client, ...) *clock.LoopFn
- func NewHTTPRecordingMiddleware(rec HTTPRecorder, next http.Handler) http.Handler
- func NewRegistry() *prometheus.Registry
- func StartServer(r *prometheus.Registry, hostname string, port int) (*httputil.HTTPServer, error)
- type CLIConfig
- type CacheMetrics
- type DocumentedMetric
- type Event
- type EventVec
- type Factory
- type HTTPParams
- type HTTPRecorder
- type NodeRecorder
- type NoopRPCMetrics
- type NoopRefMetrics
- type PromHTTPRecorder
- func (p *PromHTTPRecorder) RecordHTTPRequest(params *HTTPParams)
- func (p *PromHTTPRecorder) RecordHTTPRequestDuration(params *HTTPParams, dur time.Duration)
- func (p *PromHTTPRecorder) RecordHTTPResponse(params *HTTPParams)
- func (p *PromHTTPRecorder) RecordHTTPResponseSize(params *HTTPParams, size int)
- func (p *PromHTTPRecorder) RecordInflightRequest(params *HTTPParams, quantity int)
- type PromNodeRecorder
- type RPCClientMetricer
- type RPCClientMetrics
- type RPCMetricer
- type RPCMetrics
- type RPCServerMetricer
- type RPCServerMetrics
- type RefMetricer
- type RefMetrics
- type RegistryMetricer
Constants ¶
const ( EnabledFlagName = "metrics.enabled" ListenAddrFlagName = "metrics.addr" PortFlagName = "metrics.port" )
const ( RPCServerSubsystem = "rpc_server" RPCClientSubsystem = "rpc_client" BatchMethod = "<batch>" )
Variables ¶
var ErrInvalidPort = errors.New("invalid metrics port")
var LatencyBuckets = []float64{.025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100}
var NoopHTTPRecorder = new(noopHTTPRecorder)
var NoopNodeRecorder = new(noopNodeRecorder)
Functions ¶
func LaunchBalanceMetrics ¶
func LaunchBalanceMetrics(log log.Logger, r *prometheus.Registry, ns string, client *ethclient.Client, account common.Address) *clock.LoopFn
LaunchBalanceMetrics starts a periodic query of the balance of the supplied account and 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 NewHTTPRecordingMiddleware ¶
func NewHTTPRecordingMiddleware(rec HTTPRecorder, next http.Handler) http.Handler
func NewRegistry ¶
func NewRegistry() *prometheus.Registry
func StartServer ¶ added in v1.4.2
func StartServer(r *prometheus.Registry, hostname string, port int) (*httputil.HTTPServer, error)
Types ¶
type CLIConfig ¶
func DefaultCLIConfig ¶ added in v1.1.6
func DefaultCLIConfig() CLIConfig
func ReadCLIConfig ¶
func ReadCLIConfig(ctx *cli.Context) CLIConfig
type CacheMetrics ¶ added in v1.4.2
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 ¶ added in v1.4.2
func NewCacheMetrics(factory Factory, ns string, name string, displayName string) *CacheMetrics
func (*CacheMetrics) CacheAdd ¶ added in v1.4.2
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 ¶ added in v1.4.2
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 DocumentedMetric ¶
type Event ¶
type Event struct { Total prometheus.Counter LastTime prometheus.Gauge }
type EventVec ¶
type EventVec struct { Total prometheus.CounterVec LastTime prometheus.GaugeVec }
func NewEventVec ¶
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 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 NoopRPCMetrics ¶ added in v1.4.2
type NoopRPCMetrics struct{}
func (*NoopRPCMetrics) RecordRPCClientRequest ¶ added in v1.4.2
func (n *NoopRPCMetrics) RecordRPCClientRequest(method string) func(err error)
func (*NoopRPCMetrics) RecordRPCClientResponse ¶ added in v1.4.2
func (n *NoopRPCMetrics) RecordRPCClientResponse(method string, err error)
func (*NoopRPCMetrics) RecordRPCServerRequest ¶ added in v1.4.2
func (n *NoopRPCMetrics) RecordRPCServerRequest(method string) func()
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)
type PromHTTPRecorder ¶
type PromHTTPRecorder struct { // HTTPRequestDuration is the old metric for request latency // it was created with too tight buckets: [.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10] // in order to preserve backward compatibility we are keeping this metric for now // and it will be removed when services opt in to HTTPRequestLatency // Deprecated: HTTPRequestDuration is deprecated HTTPRequestDuration *prometheus.HistogramVec // HTTPRequestLatency measures request execution latency in *seconds* // buckets are: [.025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50] HTTPRequestLatency *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 RPCClientMetricer ¶ added in v1.7.6
type RPCClientMetrics ¶ added in v1.7.6
type RPCClientMetrics struct { RPCClientRequestsTotal *prometheus.CounterVec RPCClientRequestDurationSeconds *prometheus.HistogramVec RPCClientResponsesTotal *prometheus.CounterVec }
RPCMetrics tracks client-only RPC metrics
func MakeRPCClientMetrics ¶ added in v1.7.6
func MakeRPCClientMetrics(ns string, factory Factory) RPCClientMetrics
MakeRPCClientMetrics creates a new RPCServerMetrics instance with the given namespace
func (*RPCClientMetrics) RecordRPCClientRequest ¶ added in v1.7.6
func (m *RPCClientMetrics) 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 (*RPCClientMetrics) RecordRPCClientResponse ¶ added in v1.7.6
func (m *RPCClientMetrics) 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>.
type RPCMetricer ¶ added in v1.2.0
type RPCMetricer interface { RPCClientMetricer RPCServerMetricer }
type RPCMetrics ¶ added in v1.2.0
type RPCMetrics struct { RPCClientMetrics RPCServerMetrics }
RPCMetrics tracks all the RPC metrics, both client & server
func MakeRPCMetrics ¶ added in v1.2.0
func MakeRPCMetrics(ns string, factory Factory) RPCMetrics
MakeRPCMetrics creates a new RPCMetrics with the given namespace
type RPCServerMetricer ¶ added in v1.7.6
type RPCServerMetricer interface {
RecordRPCServerRequest(method string) func()
}
type RPCServerMetrics ¶ added in v1.7.6
type RPCServerMetrics struct { RPCServerRequestsTotal *prometheus.CounterVec RPCServerRequestDurationSeconds *prometheus.HistogramVec }
RPCMetrics tracks server-only RPC metrics
func MakeRPCServerMetrics ¶ added in v1.7.6
func MakeRPCServerMetrics(ns string, factory Factory) RPCServerMetrics
MakeRPCServerMetrics creates a new RPCServerMetrics instance with the given namespace
func (*RPCServerMetrics) RecordRPCServerRequest ¶ added in v1.7.6
func (m *RPCServerMetrics) RecordRPCServerRequest(method string) func()
RecordRPCServerRequest is a helper method to record an incoming RPC call to the opnode's RPC server. It bumps the requests metric, and tracks how long it takes to serve a response.
type RefMetricer ¶
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 constructors 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)
type RegistryMetricer ¶ added in v1.4.2
type RegistryMetricer interface {
Registry() *prometheus.Registry
}