metrics

package
v1.5.11 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0, MIT Imports: 14 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 manuy 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 added in v1.4.6

func DKGStateChange(s DKGState, beaconID string, leader bool)

DKGStateChange emits appropriate dkgState, dkgStateTimestamp and dkgLeader metrics

func ErrorSendingPartial added in v1.5.5

func ErrorSendingPartial(beaconID, address string)

func GroupHandler added in v1.0.0

func GroupHandler() http.Handler

GroupHandler provides metrics shared to other group members This HTTP handler, which would typically be mounted at `/metrics` exposes `GroupMetrics`

func RegisterClientMetrics added in v1.0.0

func RegisterClientMetrics(r prometheus.Registerer) error

RegisterClientMetrics registers drand client metrics with the given registry

func ReshareStateChange added in v1.4.6

func ReshareStateChange(s ReshareState, beaconID string, leader bool)

ReshareStateChange emits appropriate reshareState, reshareStateTimestamp and reshareLeader metrics

func Start

func Start(metricsBind string, pprof http.Handler, groupHandlers []Handler) net.Listener

Start starts a prometheus metrics server with debug endpoints.

func SuccessfulPartial added in v1.5.5

func SuccessfulPartial(beaconID, address string)

Types

type DKGState added in v1.4.6

type DKGState int
const (
	DKGNotStarted   DKGState = 0
	DKGWaiting      DKGState = 1
	DKGInProgress   DKGState = 2
	DKGDone         DKGState = 3
	DKGUnknownState DKGState = 4
	DKGShutdown     DKGState = 5
)

If you change any of these constants, be sure to change them in the appropriate metric help message below, and in the dashboards!

type Handler added in v1.4.6

type Handler func(addr string) (http.Handler, error)

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

type ReshareState added in v1.4.6

type ReshareState int
const (
	ReshareIdle         ReshareState = 0
	ReshareWaiting      ReshareState = 1
	ReshareInProgess    ReshareState = 2
	ReshareUnknownState ReshareState = 3
	ReshareShutdown     ReshareState = 4
)

type ThresholdMonitor added in v1.5.5

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

func NewThresholdMonitor added in v1.5.5

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

func (*ThresholdMonitor) ReportFailure added in v1.5.5

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

func (*ThresholdMonitor) Start added in v1.5.5

func (t *ThresholdMonitor) Start()

func (*ThresholdMonitor) Stop added in v1.5.5

func (t *ThresholdMonitor) Stop()

func (*ThresholdMonitor) UpdateThreshold added in v1.5.5

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