Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector receives MetricEvents on a buffered channel and persists them asynchronously via a callback. Events are dropped (never blocked) if the channel is full, so the agent is never slowed down.
func NewCollector ¶
func NewCollector(capacity int, persist func(MetricEvent)) *Collector
NewCollector starts a background goroutine that drains ch and calls persist for each event. cap is the channel buffer size (256 is a good default).
func (*Collector) Emit ¶
func (c *Collector) Emit(m MetricEvent)
Emit sends a metric event to the collector. Non-blocking: drops if full.
type MetricEvent ¶
type MetricEvent struct {
Timestamp time.Time `json:"timestamp"`
TurnIndex int `json:"turn_index"`
Type string `json:"type"` // "llm" or "tool"
// LLM metrics
TTFT time.Duration `json:"ttft,omitempty"` // time to first text/reasoning token
ThinkTime time.Duration `json:"think_time,omitempty"` // cumulative reasoning/thinking duration
Duration time.Duration `json:"duration,omitempty"` // total LLM call wall time
// Tool metrics
ToolName string `json:"tool_name,omitempty"`
ToolSuccess bool `json:"tool_success,omitempty"`
ToolError string `json:"tool_error,omitempty"`
ToolDuration time.Duration `json:"tool_duration,omitempty"`
// Metadata
Model string `json:"model,omitempty"`
Vendor string `json:"vendor,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
}
MetricEvent records a single performance measurement — either an LLM API call or a tool execution. Designed to be fire-and-forget: the agent emits these via a callback, and the caller persists them asynchronously.
type SessionSummary ¶ added in v1.3.44
type SessionSummary struct {
TurnCount int
LLMCallCount int
ToolCallCount int
ToolFailureCount int
AvgTTFT time.Duration
P95TTFT time.Duration
AvgDuration time.Duration
P95Duration time.Duration
AvgThink time.Duration
SlowTools []ToolSummary
Turns []TurnSummary
}
func Summarize ¶ added in v1.3.44
func Summarize(events []MetricEvent) SessionSummary
func (SessionSummary) HasData ¶ added in v1.3.44
func (s SessionSummary) HasData() bool
func (SessionSummary) ToolFailureRate ¶ added in v1.3.44
func (s SessionSummary) ToolFailureRate() int