metrics

package
v0.4.2 Latest Latest
Warning

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

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

Documentation

Index

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 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) RecordChannelSend

func (m *RuntimeMetrics) RecordChannelSend(success bool) (RuntimeSnapshot, error)

RecordChannelSend updates outbound channel send metrics and persists the snapshot.

func (*RuntimeMetrics) RecordToolExecution

func (m *RuntimeMetrics) RecordToolExecution(duration time.Duration, result string, runErr error) (RuntimeSnapshot, error)

RecordToolExecution updates tool metrics and persists the snapshot.

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"`
}

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

func (t ToolStats) AvgLatencyMs() float64

AvgLatencyMs returns average latency in milliseconds.

func (ToolStats) ErrorRatio

func (t ToolStats) ErrorRatio() float64

ErrorRatio returns errors/total in [0,1].

func (ToolStats) TimeoutRatio

func (t ToolStats) TimeoutRatio() float64

TimeoutRatio returns timeouts/total in [0,1].

Jump to

Keyboard shortcuts

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