Documentation
¶
Index ¶
- type ChannelStats
- type MemoryStats
- type RuntimeMetrics
- func (m *RuntimeMetrics) Close() error
- func (m *RuntimeMetrics) Flush()
- func (m *RuntimeMetrics) RecordChannelSend(success bool) (RuntimeSnapshot, error)
- func (m *RuntimeMetrics) RecordMemoryRecall(itemCount int, sourceHits map[string]int) (RuntimeSnapshot, error)
- func (m *RuntimeMetrics) RecordToolExecution(duration time.Duration, result string, runErr error) (RuntimeSnapshot, error)
- func (m *RuntimeMetrics) Snapshot() RuntimeSnapshot
- type RuntimeSnapshot
- type ToolStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelStats ¶
type ChannelStats struct {
SendAttempts int64 `json:"send_attempts"`
SendFailures int64 `json:"send_failures"`
}
ChannelStats tracks outbound channel send metrics.
func (ChannelStats) FailureRatio ¶
func (c ChannelStats) FailureRatio() float64
FailureRatio returns failures/attempts in [0,1].
type MemoryStats ¶ added in v0.5.0
type MemoryStats struct {
Recalls int64 `json:"recalls"`
TotalItems int64 `json:"total_items"`
LastItems int64 `json:"last_items"`
EmptyRecalls int64 `json:"empty_recalls"`
LongTermHits int64 `json:"long_term_hits"`
DiaryRecentHits int64 `json:"diary_recent_hits"`
DiaryKeywordHits int64 `json:"diary_keyword_hits"`
}
MemoryStats tracks memory recall observability.
type RuntimeMetrics ¶
type RuntimeMetrics struct {
// contains filtered or unexported fields
}
RuntimeMetrics records and persists runtime metrics.
func NewRuntimeMetrics ¶
func NewRuntimeMetrics(workspacePath string) *RuntimeMetrics
NewRuntimeMetrics creates a metrics recorder rooted at <workspace>/state/runtime_metrics.json.
func (*RuntimeMetrics) Close ¶ added in v0.6.3
func (m *RuntimeMetrics) Close() error
Close stops the flusher and ensures final persistence.
func (*RuntimeMetrics) Flush ¶ added in v0.6.3
func (m *RuntimeMetrics) Flush()
Flush forces persistence of the snapshot if dirty.
func (*RuntimeMetrics) RecordChannelSend ¶
func (m *RuntimeMetrics) RecordChannelSend(success bool) (RuntimeSnapshot, error)
RecordChannelSend updates outbound channel send metrics and marks for persistence.
func (*RuntimeMetrics) RecordMemoryRecall ¶ added in v0.5.0
func (m *RuntimeMetrics) RecordMemoryRecall(itemCount int, sourceHits map[string]int) (RuntimeSnapshot, error)
RecordMemoryRecall records memory recall count and hit-source breakdown.
func (*RuntimeMetrics) RecordToolExecution ¶
func (m *RuntimeMetrics) RecordToolExecution(duration time.Duration, result string, runErr error) (RuntimeSnapshot, error)
RecordToolExecution updates tool metrics and marks for persistence.
func (*RuntimeMetrics) Snapshot ¶
func (m *RuntimeMetrics) Snapshot() RuntimeSnapshot
Snapshot returns the latest in-memory snapshot.
type RuntimeSnapshot ¶
type RuntimeSnapshot struct {
UpdatedAt time.Time `json:"updated_at"`
Tool ToolStats `json:"tool"`
Channel ChannelStats `json:"channel"`
Memory MemoryStats `json:"memory"`
}
RuntimeSnapshot contains aggregated runtime metrics for tools and channel sends.
func ReadRuntimeSnapshot ¶
func ReadRuntimeSnapshot(workspacePath string) (RuntimeSnapshot, error)
ReadRuntimeSnapshot reads the persisted snapshot from workspace state. If no file exists yet, it returns a zero-value snapshot and nil error.
func (RuntimeSnapshot) HasData ¶
func (s RuntimeSnapshot) HasData() bool
HasData reports whether any runtime metrics were recorded.
type ToolStats ¶
type ToolStats struct {
Total int64 `json:"total"`
Errors int64 `json:"errors"`
Timeouts int64 `json:"timeouts"`
TotalLatencyMs int64 `json:"total_latency_ms"`
MaxLatencyMs int64 `json:"max_latency_ms"`
LastLatencyMs int64 `json:"last_latency_ms"`
P95ProxyLatencyMs int64 `json:"p95_proxy_latency_ms"`
}
ToolStats tracks tool execution metrics.
func (ToolStats) AvgLatencyMs ¶
AvgLatencyMs returns average latency in milliseconds.
func (ToolStats) ErrorRatio ¶
ErrorRatio returns errors/total in [0,1].
func (ToolStats) TimeoutRatio ¶
TimeoutRatio returns timeouts/total in [0,1].