observability

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HealthHandler

func HealthHandler() http.HandlerFunc

HealthHandler returns an HTTP handler for health checks

func InitMetrics

func InitMetrics()

InitMetrics initializes Prometheus metrics

func LivenessHandler

func LivenessHandler() http.HandlerFunc

LivenessHandler returns a simple liveness probe handler

func MetricsHandler

func MetricsHandler() http.Handler

MetricsHandler returns an HTTP handler for Prometheus metrics

func ReadinessHandler

func ReadinessHandler() http.HandlerFunc

ReadinessHandler returns a readiness probe handler

func RecordAgentExecution

func RecordAgentExecution(agent string, duration time.Duration)

RecordAgentExecution records agent execution metrics

func RecordAgentMessage

func RecordAgentMessage(agent, msgType string)

RecordAgentMessage records agent message metrics

func RecordGRPCRequest

func RecordGRPCRequest(method, status string, duration time.Duration)

RecordGRPCRequest records gRPC request metrics

func RecordHTTPRequest

func RecordHTTPRequest(method, path, status string, duration time.Duration)

RecordHTTPRequest records HTTP request metrics

func RecordMCPToolCall

func RecordMCPToolCall(tool, status string, duration time.Duration)

RecordMCPToolCall records MCP tool call metrics

func SetActiveConnections

func SetActiveConnections(count int)

SetActiveConnections sets the active connections gauge

func SetGoroutines

func SetGoroutines(count int)

SetGoroutines sets the goroutines gauge

func SetMemoryUsage

func SetMemoryUsage(bytes uint64)

SetMemoryUsage sets the memory usage gauge

Types

type CheckStatus

type CheckStatus struct {
	Status      HealthStatus `json:"status"`
	Message     string       `json:"message,omitempty"`
	LastChecked time.Time    `json:"last_checked"`
	Duration    string       `json:"duration,omitempty"`
}

CheckStatus represents the status of a health check

type HealthCheck

type HealthCheck struct {
	Name      string
	CheckFunc func(context.Context) error
	Timeout   time.Duration
	Critical  bool
	// contains filtered or unexported fields
}

HealthCheck represents a single health check

func DatabaseCheck

func DatabaseCheck(pingFunc func(context.Context) error) *HealthCheck

DatabaseCheck creates a database health check

func ExternalServiceCheck

func ExternalServiceCheck(name string, checkFunc func(context.Context) error) *HealthCheck

ExternalServiceCheck creates an external service health check

func PingCheck

func PingCheck() *HealthCheck

PingCheck creates a simple ping health check

type HealthChecker

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

HealthChecker manages health checks

func GetHealthChecker

func GetHealthChecker() *HealthChecker

GetHealthChecker returns the global health checker

func InitHealthChecker

func InitHealthChecker() *HealthChecker

InitHealthChecker initializes the global health checker

func (*HealthChecker) Check

Check performs all health checks

func (*HealthChecker) RegisterCheck

func (hc *HealthChecker) RegisterCheck(check *HealthCheck)

RegisterCheck registers a new health check

type HealthResponse

type HealthResponse struct {
	Status    HealthStatus           `json:"status"`
	Timestamp time.Time              `json:"timestamp"`
	Version   string                 `json:"version"`
	Uptime    time.Duration          `json:"uptime"`
	Checks    map[string]CheckStatus `json:"checks"`
	System    SystemInfo             `json:"system"`
}

HealthResponse represents the health check response

type HealthStatus

type HealthStatus string

HealthStatus represents the health status of the service

const (
	HealthStatusHealthy   HealthStatus = "healthy"
	HealthStatusDegraded  HealthStatus = "degraded"
	HealthStatusUnhealthy HealthStatus = "unhealthy"
)

type Server

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

Server provides HTTP endpoints for observability

func NewServer

func NewServer(port int) *Server

NewServer creates a new observability server

func (*Server) Shutdown

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

Shutdown gracefully shuts down the server

func (*Server) Start

func (s *Server) Start() error

Start starts the observability server

type SystemInfo

type SystemInfo struct {
	NumGoroutines int    `json:"num_goroutines"`
	NumCPU        int    `json:"num_cpu"`
	MemAlloc      uint64 `json:"mem_alloc_mb"`
	MemSys        uint64 `json:"mem_sys_mb"`
}

SystemInfo represents system information

Jump to

Keyboard shortcuts

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