metrics

package
v0.1.0-proto2j Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Build Info
	BuildInfo = factory.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "gapi_build_info",
			Help: "Supervisor build information",
		},
		[]string{"version", "commit", "go_version"},
	)

	// Supervisor Metrics
	SupervisorUptime = factory.NewGauge(
		prometheus.GaugeOpts{
			Name: "gapi_supervisor_uptime_seconds",
			Help: "Supervisor uptime in seconds",
		},
	)

	AgentsTotal = factory.NewGauge(
		prometheus.GaugeOpts{
			Name: "gapi_supervisor_agents_total",
			Help: "Total number of registered agents",
		},
	)

	// Agent Lifecycle Metrics
	AgentState = factory.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "gapi_agent_state",
			Help: "Current state of agents (1 = in this state, 0 = not)",
		},
		[]string{"id", "type", "state"},
	)

	AgentStarts = factory.NewCounterVec(
		prometheus.CounterOpts{
			Name: "gapi_agent_starts_total",
			Help: "Total number of agent starts",
		},
		[]string{"id", "type"},
	)

	AgentStops = factory.NewCounterVec(
		prometheus.CounterOpts{
			Name: "gapi_agent_stops_total",
			Help: "Total number of agent stops",
		},
		[]string{"id", "type"},
	)

	AgentFailures = factory.NewCounterVec(
		prometheus.CounterOpts{
			Name: "gapi_agent_failures_total",
			Help: "Total number of agent failures",
		},
		[]string{"id", "type", "reason"},
	)

	// Resource Usage Metrics
	AgentCPUUsage = factory.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "gapi_agent_cpu_usage",
			Help: "Agent CPU usage percentage",
		},
		[]string{"id", "type"},
	)

	AgentMemoryBytes = factory.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "gapi_agent_memory_bytes",
			Help: "Agent memory usage in bytes",
		},
		[]string{"id", "type"},
	)

	AgentUptimeSeconds = factory.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "gapi_agent_uptime_seconds",
			Help: "Agent uptime in seconds",
		},
		[]string{"id", "type"},
	)

	// EventBus Metrics
	EventBusEvents = factory.NewCounterVec(
		prometheus.CounterOpts{
			Name: "gapi_eventbus_events_total",
			Help: "Total number of events published",
		},
		[]string{"topic"},
	)

	EventBusSubscribers = factory.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "gapi_eventbus_subscribers",
			Help: "Number of active subscribers per topic",
		},
		[]string{"topic"},
	)
)

The gapi_ metric NAMES below are deliberately not product-namespaced, and this is an exclusion rather than an oversight (GAPI-DIV-061).

A metric name is scraped: it is referenced by dashboards, recording rules and alerts that live outside this repo, so renaming one breaks consumers exactly the way renaming an ALPN or a protobuf package would. They belong to the WIRE class. The HELP text next to them does not - nobody alerts on help text - which is why the two lines that spelled the vendor there now name the role instead.

Registry is a dedicated registry for all GAPI metrics. Registering against it (rather than prometheus.DefaultRegisterer) means host applications that embed GAPI and replace the default registry still expose GAPI metrics via Handler().

Functions

func Handler

func Handler() http.Handler

Handler returns an http.Handler that serves the GAPI metric Registry.

func RecordAgentFailure

func RecordAgentFailure(id, agentType, reason string)

RecordAgentFailure increments agent failure counter

func RecordAgentStart

func RecordAgentStart(id, agentType string)

RecordAgentStart increments agent start counter

func RecordAgentStateChange

func RecordAgentStateChange(id, agentType, oldState, newState string)

RecordAgentStateChange updates agent state metrics

func RecordAgentStop

func RecordAgentStop(id, agentType string)

RecordAgentStop increments agent stop counter

func RecordEvent

func RecordEvent(topic string)

RecordEvent increments event counter for a topic

func UpdateAgentResources

func UpdateAgentResources(id, agentType string, cpuUsage float64, memoryBytes uint64, uptimeSeconds float64)

UpdateAgentResources updates agent resource usage metrics

func UpdateSubscriberCount

func UpdateSubscriberCount(topic string, count int)

UpdateSubscriberCount updates subscriber count for a topic

Types

type Server

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

Server provides an HTTP endpoint for Prometheus metrics

func NewServer

func NewServer(addr string, logger *slog.Logger) *Server

NewServer creates a new metrics server

func (*Server) Start

func (s *Server) Start() error

Start starts the metrics HTTP server

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop gracefully stops the metrics server

Jump to

Keyboard shortcuts

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