Documentation
¶
Overview ¶
Package metrics provides daemon-wide atomic counters for observability. Distinct from supervisor.Metrics which tracks per-process ring-buffer stats; this package tracks daemon-level aggregate counters.
Index ¶
- Constants
- func NormalizeReapReason(reason string) string
- type DaemonMetrics
- func (m *DaemonMetrics) DecSessionsActive()
- func (m *DaemonMetrics) DecSubprocessesActive()
- func (m *DaemonMetrics) IncErrors()
- func (m *DaemonMetrics) IncSessionsActive()
- func (m *DaemonMetrics) IncSubprocessesActive()
- func (m *DaemonMetrics) IncToolCalls()
- func (m *DaemonMetrics) Snapshot() Snapshot
- type ServerMetrics
- type ServerMetricsReporter
- type ServerMetricsSnapshot
- type Snapshot
Constants ¶
const ( ReapReasonClientDisconnected = "client_disconnected" ReapReasonIdleTimeout = "idle_timeout" ReapReasonUpstreamDelete = "upstream_delete" ReapReasonSessionRemoved = "session_removed" ReapReasonHealthCheck = "health_check" ReapReasonToolsListFailed = "tools_list_failed" ReapReasonProcessLost = "process_lost" ReapReasonListenerClosed = "listener_closed" ReapReasonUnknown = "unknown" )
Variables ¶
This section is empty.
Functions ¶
func NormalizeReapReason ¶ added in v1.2.5
NormalizeReapReason maps legacy close reason text to canonical metrics keys. Unknown input collapses to "unknown" to avoid unbounded metric cardinality.
Types ¶
type DaemonMetrics ¶
type DaemonMetrics struct {
// contains filtered or unexported fields
}
DaemonMetrics provides thread-safe daemon-wide counters using sync/atomic.
func NewDaemonMetrics ¶
func NewDaemonMetrics() *DaemonMetrics
NewDaemonMetrics creates a new zeroed DaemonMetrics.
func (*DaemonMetrics) DecSessionsActive ¶
func (m *DaemonMetrics) DecSessionsActive()
DecSessionsActive atomically decrements the active session counter.
func (*DaemonMetrics) DecSubprocessesActive ¶
func (m *DaemonMetrics) DecSubprocessesActive()
DecSubprocessesActive atomically decrements the active subprocess counter.
func (*DaemonMetrics) IncErrors ¶
func (m *DaemonMetrics) IncErrors()
IncErrors atomically increments the error counter.
func (*DaemonMetrics) IncSessionsActive ¶
func (m *DaemonMetrics) IncSessionsActive()
IncSessionsActive atomically increments the active session counter.
func (*DaemonMetrics) IncSubprocessesActive ¶
func (m *DaemonMetrics) IncSubprocessesActive()
IncSubprocessesActive atomically increments the active subprocess counter.
func (*DaemonMetrics) IncToolCalls ¶
func (m *DaemonMetrics) IncToolCalls()
IncToolCalls atomically increments the tool call counter.
func (*DaemonMetrics) Snapshot ¶
func (m *DaemonMetrics) Snapshot() Snapshot
Snapshot returns a point-in-time copy of all counters.
type ServerMetrics ¶ added in v1.2.5
type ServerMetrics struct {
// contains filtered or unexported fields
}
ServerMetrics provides thread-safe per-server counters using sync/atomic. Tracks active sessions, reap counts by reason, and admission denials.
func NewServerMetrics ¶ added in v1.2.5
func NewServerMetrics() *ServerMetrics
NewServerMetrics creates a new zeroed ServerMetrics.
func (*ServerMetrics) DecActiveSessions ¶ added in v1.2.5
func (m *ServerMetrics) DecActiveSessions()
DecActiveSessions atomically decrements the active session counter.
func (*ServerMetrics) IncActiveSessions ¶ added in v1.2.5
func (m *ServerMetrics) IncActiveSessions()
IncActiveSessions atomically increments the active session counter.
func (*ServerMetrics) IncAdmissionDenied ¶ added in v1.2.5
func (m *ServerMetrics) IncAdmissionDenied()
IncAdmissionDenied atomically increments the admission denial counter.
func (*ServerMetrics) IncReaped ¶ added in v1.2.5
func (m *ServerMetrics) IncReaped(reason string)
IncReaped increments the reap counter for the given reason. Reasons are normalized to bounded canonical keys before counting.
func (*ServerMetrics) Snapshot ¶ added in v1.2.5
func (m *ServerMetrics) Snapshot() ServerMetricsSnapshot
Snapshot returns a point-in-time copy of all per-server counters.
type ServerMetricsReporter ¶ added in v1.2.5
type ServerMetricsReporter interface {
IncActiveSessions()
DecActiveSessions()
IncAdmissionDenied()
IncReaped(reason string)
}
ServerMetricsReporter decouples consumers from concrete ServerMetrics. SharedSessionManager uses this interface so tests can inject stubs.
type ServerMetricsSnapshot ¶ added in v1.2.5
type ServerMetricsSnapshot struct {
ActiveSessions int64 `json:"active_sessions"`
ReapedByReason map[string]int64 `json:"reaped_by_reason"`
AdmissionDenied int64 `json:"admission_denied"`
}
ServerMetricsSnapshot holds a point-in-time copy of per-server metrics.