metrics

package
v1.65.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT

* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT

* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT

* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT

* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT

* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT

Index

Constants

View Source
const (
	// Namespace is the Prometheus namespace for all ChatCLI metrics.
	Namespace = "chatcli"
)

Variables

Registry is the custom Prometheus registry for ChatCLI. Using a custom registry avoids polluting the global default and gives full control over which collectors are active.

Functions

This section is empty.

Types

type GRPCMetrics

type GRPCMetrics struct {
	RequestsTotal      *prometheus.CounterVec
	RequestDuration    *prometheus.HistogramVec
	InFlightRequests   *prometheus.GaugeVec
	StreamMsgsSent     *prometheus.CounterVec
	StreamMsgsReceived *prometheus.CounterVec
}

GRPCMetrics holds Prometheus metrics for gRPC server instrumentation.

func NewGRPCMetrics

func NewGRPCMetrics() *GRPCMetrics

NewGRPCMetrics creates and registers gRPC metrics on the custom registry.

func (*GRPCMetrics) StreamInterceptor

func (m *GRPCMetrics) StreamInterceptor() grpc.StreamServerInterceptor

StreamInterceptor returns a gRPC stream server interceptor that records metrics.

func (*GRPCMetrics) UnaryInterceptor

func (m *GRPCMetrics) UnaryInterceptor() grpc.UnaryServerInterceptor

UnaryInterceptor returns a gRPC unary server interceptor that records metrics.

type LLMMetrics

type LLMMetrics struct {
	RequestsTotal   *prometheus.CounterVec
	RequestDuration *prometheus.HistogramVec
	TokensUsed      *prometheus.CounterVec
	ErrorsTotal     *prometheus.CounterVec
}

LLMMetrics holds Prometheus metrics for LLM provider interactions.

func NewLLMMetrics

func NewLLMMetrics() *LLMMetrics

NewLLMMetrics creates and registers LLM metrics.

type Server

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

Server serves the /metrics HTTP endpoint for Prometheus scraping.

func NewServer

func NewServer(port int, logger *zap.Logger) *Server

NewServer creates a metrics HTTP server on the given port. Pass port=0 to disable.

func (*Server) Start

func (s *Server) Start()

Start begins serving metrics. Non-blocking — runs in background goroutine.

func (*Server) Stop

func (s *Server) Stop()

Stop gracefully shuts down the metrics server.

type ServerMetrics

type ServerMetrics struct {
	Info *prometheus.GaugeVec
	// contains filtered or unexported fields
}

ServerMetrics holds Prometheus metrics for server-level information.

func NewServerMetrics

func NewServerMetrics(version, provider, model string, startTime time.Time) *ServerMetrics

NewServerMetrics creates and registers server metrics. startTime is the server boot time used to compute uptime.

type SessionMetrics

type SessionMetrics struct {
	ActiveSessions  prometheus.Gauge
	OperationsTotal *prometheus.CounterVec
}

SessionMetrics holds Prometheus metrics for session management.

func NewSessionMetrics

func NewSessionMetrics() *SessionMetrics

NewSessionMetrics creates and registers session metrics.

type WatcherMetrics

type WatcherMetrics struct {
	CollectionDuration *prometheus.HistogramVec
	CollectionErrors   *prometheus.CounterVec
	AlertsTotal        *prometheus.CounterVec
	TargetsMonitored   prometheus.Gauge
	PodsReady          *prometheus.GaugeVec
	PodsDesired        *prometheus.GaugeVec
	SnapshotsStored    *prometheus.GaugeVec
	PodRestarts        *prometheus.GaugeVec
}

WatcherMetrics holds Prometheus metrics for the K8s watcher subsystem.

func NewWatcherMetrics

func NewWatcherMetrics() *WatcherMetrics

NewWatcherMetrics creates and registers watcher metrics.

func (*WatcherMetrics) Recorder

func (m *WatcherMetrics) Recorder() WatcherMetricsRecorder

Recorder returns a WatcherMetricsRecorder backed by this WatcherMetrics.

type WatcherMetricsRecorder

type WatcherMetricsRecorder interface {
	ObserveCollectionDuration(target string, seconds float64)
	IncrementCollectionErrors(target string)
	IncrementAlert(target, severity, alertType string)
	SetPodsReady(namespace, deployment string, count float64)
	SetPodsDesired(namespace, deployment string, count float64)
	SetSnapshotsStored(target string, count float64)
	SetPodRestarts(target string, count float64)
}

WatcherMetricsRecorder is the interface that the k8s package uses to record watcher metrics without importing the metrics package directly. This avoids circular dependencies between k8s/ and metrics/.

Jump to

Keyboard shortcuts

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