metrics

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NodeCounts is a gauge that tracks the number of available nodes for each type
	NodeCounts = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "proxy_node_count",
			Help: "Number of healthy nodes for each type",
		},
		[]string{"type"},
	)

	// RequestCount is a counter that tracks the number of requests per node for each type.
	// It has the following labels:
	//   - type: The type of request (rest/rpc/grpc)
	//   - node: The node handling the request
	RequestCount = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "proxy_request_count",
			Help: "Number of requests per node for each type",
		},
		[]string{"type", "node"},
	)

	// RequestStatusCount is a counter that tracks the number of requests by status code.
	// It has the following labels:
	//   - type: The type of request (rest/rpc/grpc)
	//   - node: The node handling the request
	//   - status_code: The HTTP status code of the response
	RequestStatusCount = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "proxy_request_status_count",
			Help: "Number of requests by status code",
		},
		[]string{"type", "node", "status_code"},
	)

	// NodeHealth is a gauge that tracks the health status of each node
	// It has the following labels:
	//   - type: The type of node (rest/rpc/grpc)
	//   - node: The node identifier (usually the host)
	// Value is 1 if healthy, 0 if unhealthy
	NodeHealth = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "proxy_node_health",
			Help: "Health status of each node (1 = healthy, 0 = unhealthy)",
		},
		[]string{"type", "node"},
	)
)

Functions

func IncrementRequestCount

func IncrementRequestCount(requestType, node string)

IncrementRequestCount increments the request count for a specific type and node

func IncrementRequestStatusCount

func IncrementRequestStatusCount(requestType, node string, statusCode int)

IncrementRequestStatusCount increments the request count for a specific type, node, and status code

func PrepareMetricsServer

func PrepareMetricsServer(addr string, path string) *http.Server

PrepareMetricsServer prepares a new HTTP server for Prometheus metrics

func UpdateNodeCount

func UpdateNodeCount(nodeType string, count float64)

UpdateNodeCount updates the node count for a specific type

func UpdateNodeHealth

func UpdateNodeHealth(nodeType, node string, healthy bool)

UpdateNodeHealth updates the health status for a specific node

Types

This section is empty.

Jump to

Keyboard shortcuts

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