metrics

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: MIT Imports: 12 Imported by: 15

Documentation

Index

Constants

View Source
const (
	Namespace = "op_node"

	RPCServerSubsystem = "rpc_server"
	RPCClientSubsystem = "rpc_client"

	BatchMethod = "<batch>"
)

Variables

This section is empty.

Functions

This section is empty.

Types

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
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(procName string) *Metrics

func (*Metrics) RecordInfo

func (m *Metrics) RecordInfo(version string)

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

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 opnode's RPC server. It bumps the requests metric, and tracks how long it takes to serve a response.

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.

Jump to

Keyboard shortcuts

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