metrics

package
v2.0.5-testnet Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: Apache-2.0, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PrivateMetrics about the internal world (go process, private stuff)
	PrivateMetrics = prometheus.NewRegistry()
	// HTTPMetrics about the public surface area (http requests, cdn stuff)
	HTTPMetrics = prometheus.NewRegistry()
	// GroupMetrics about the group surface (grp, group-member stuff)
	GroupMetrics = prometheus.NewRegistry()
	// ClientMetrics about the drand client requests to servers
	ClientMetrics = prometheus.NewRegistry()

	// APICallCounter (Group) how many grpc calls
	APICallCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "api_call_counter",
		Help: "Number of API calls that we have received",
	}, []string{"api_method"})

	// GroupDialFailures (Group) how many failures connecting outbound
	GroupDialFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "dial_failures",
		Help: "Number of times there have been network connection issues",
	}, []string{"peer_address"})

	// OutgoingConnections (Group) how many GrpcClient connections are present
	OutgoingConnections = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "outgoing_group_connections",
		Help: "Number of peers with current outgoing GrpcClient connections",
	})

	GroupSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "group_size",
		Help: "Number of peers in the current group",
	}, []string{"beacon_id"})

	GroupThreshold = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "group_threshold",
		Help: "Number of shares needed for beacon reconstruction",
	}, []string{"beacon_id"})

	// BeaconDiscrepancyLatency (Group) millisecond duration between time beacon created and
	// calculated time of round.
	BeaconDiscrepancyLatency = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "beacon_discrepancy_latency",
		Help: "Discrepancy between beacon creation time and calculated round time",
	}, []string{"beacon_id"})

	// LastBeaconRound is the most recent round (as also seen at /health) stored.
	LastBeaconRound = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "last_beacon_round",
		Help: "Last locally stored beacon",
	}, []string{"beacon_id"})

	// HTTPCallCounter (HTTP) how many http requests
	HTTPCallCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "http_call_counter",
		Help: "Number of HTTP calls received",
	}, []string{"code", "method"})
	// HTTPLatency (HTTP) how long http request handling takes
	HTTPLatency = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:        "http_response_duration",
		Help:        "histogram of request latencies",
		Buckets:     prometheus.DefBuckets,
		ConstLabels: prometheus.Labels{"handler": "http"},
	}, []string{"method"})
	// HTTPInFlight (HTTP) how many http requests exist
	HTTPInFlight = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "http_in_flight",
		Help: "A gauge of requests currently being served.",
	})

	// ClientWatchLatency measures the latency of the watch channel from the client's perspective.
	ClientWatchLatency = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "client_watch_latency",
		Help: "Duration between time round received and time round expected.",
	})

	// ClientHTTPHeartbeatSuccess measures the success rate of HTTP hearbeat randomness requests.
	ClientHTTPHeartbeatSuccess = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "client_http_heartbeat_success",
		Help: "Number of successful HTTP heartbeats.",
	}, []string{"http_address"})

	// ClientHTTPHeartbeatFailure measures the number of times HTTP heartbeats fail.
	ClientHTTPHeartbeatFailure = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "client_http_heartbeat_failure",
		Help: "Number of unsuccessful HTTP heartbeats.",
	}, []string{"http_address"})

	// ClientHTTPHeartbeatLatency measures the randomness latency of an HTTP source.
	ClientHTTPHeartbeatLatency = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "client_http_heartbeat_latency",
		Help: "Randomness latency of an HTTP source.",
	}, []string{"http_address"})

	// ClientInFlight measures how many active requests have been made
	ClientInFlight = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "client_in_flight",
		Help: "A gauge of in-flight drand client http requests.",
	},
		[]string{"url"},
	)

	// ClientRequests measures how many total requests have been made
	ClientRequests = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "client_api_requests_total",
			Help: "A counter for requests from the drand client.",
		},
		[]string{"code", "method", "url"},
	)

	// ClientDNSLatencyVec tracks the observed DNS resolution times
	ClientDNSLatencyVec = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "client_dns_duration_seconds",
			Help:    "Client drand dns latency histogram.",
			Buckets: []float64{.005, .01, .025, .05},
		},
		[]string{"event", "url"},
	)

	// ClientTLSLatencyVec tracks observed TLS connection times
	ClientTLSLatencyVec = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "client_tls_duration_seconds",
			Help:    "Client drand tls latency histogram.",
			Buckets: []float64{.05, .1, .25, .5},
		},
		[]string{"event", "url"},
	)

	// ClientLatencyVec tracks raw http request latencies
	ClientLatencyVec = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "client_request_duration_seconds",
			Help:    "A histogram of client request latencies.",
			Buckets: prometheus.DefBuckets,
		},
		[]string{"url"},
	)

	// IsDrandNode (Group) is 1 for drand nodes, 0 for relays
	IsDrandNode = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "is_drand_node",
		Help: "1 for drand nodes, not emitted for relays",
	})

	// DrandStorageBackend reports the database the node is running with
	DrandStorageBackend = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "drand_node_db",
		Help: "The database type the node is running with. 1=bolt, 2=postgres, 3=memdb",
	}, []string{"db_type"})

	// OutgoingConnectionState (Group) tracks the state of an outgoing connection, according to
	// https://github.com/grpc/grpc-go/blob/master/connectivity/connectivity.go#L51
	// Due to the fact that grpc-go doesn't support adding a listener for state tracking, this is
	// emitted only when getting a connection to the remote host. This means that:
	// * If a non-PL host is unable to connect to a PL host, the metric will not be sent to InfluxDB
	// * The state might not be up to date (e.g. the remote host is disconnected but we haven't
	//   tried to connect to it)
	OutgoingConnectionState = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "outgoing_connection_state",
		Help: "State of an outgoing connection. 0=Idle, 1=Connecting, 2=Ready, 3=Transient Failure, 4=Shutdown",
	}, []string{"remote_host"})

	// DrandStartTimestamp (group) contains the timestamp in seconds since the epoch of the drand process startup
	DrandStartTimestamp = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "drand_start_timestamp",
		Help: "Timestamp when the drand process started up in seconds since the Epoch",
	})

	ErrorSendingPartialCounter = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "error_sending_partial",
		Help: "Number of errors sending partial beacons to nodes. A good proxy for whether nodes are up or down. " +
			"1 = Error occurred, 0 = No error occurred",
	}, []string{"beaconID", "address"})
)

Functions

func DKGStateChange

func DKGStateChange(beaconID string, epoch uint32, leader bool, state uint32)

DKGStateChange emits appropriate dkgState, dkgStateTimestamp and dkgLeader metrics

func ErrorSendingPartial

func ErrorSendingPartial(beaconID, address string)

func RegisterClientMetrics

func RegisterClientMetrics(r prometheus.Registerer) error

RegisterClientMetrics registers drand client metrics with the given registry

func Start

func Start(logger log.Logger, metricsBind string, pprof http.Handler, cli Client) net.Listener

Start starts a prometheus metrics server with debug endpoints. If metricsBind is 0 it will use an available port.

func SuccessfulPartial

func SuccessfulPartial(beaconID, address string)

Types

type Client

type Client interface {
	GetMetrics(ctx context.Context, p string) (string, error)
}

Client is the same as net.MetricsClient but avoids cyclic dependencies in our metric and net code.

type Handler

type Handler func(ctx context.Context, addr string) (http.Handler, error)

Handler abstracts a helper for relaying http requests to a group peer

type ThresholdMonitor

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

func NewThresholdMonitor

func NewThresholdMonitor(beaconID string, l log.Logger, threshold int) *ThresholdMonitor

func (*ThresholdMonitor) ReportFailure

func (t *ThresholdMonitor) ReportFailure(beaconID, addr string)

func (*ThresholdMonitor) Start

func (t *ThresholdMonitor) Start()

func (*ThresholdMonitor) Stop

func (t *ThresholdMonitor) Stop()

func (*ThresholdMonitor) UpdateThreshold

func (t *ThresholdMonitor) UpdateThreshold(newThreshold int)

Directories

Path Synopsis
Package pprof is separated out from metrics to isolate the 'init' functionality of pprof, so that it is included when used by binaries, but not if other drand packages get used or integrated into clients that don't expect the pprof side effect to have taken effect.
Package pprof is separated out from metrics to isolate the 'init' functionality of pprof, so that it is included when used by binaries, but not if other drand packages get used or integrated into clients that don't expect the pprof side effect to have taken effect.

Jump to

Keyboard shortcuts

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