observability

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentMetric

type AgentMetric struct {
	Name         string
	InputTokens  int64
	OutputTokens int64
	ToolCalls    int64
}

AgentMetric aggregates metrics for a single agent.

type MetricsCollector

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

MetricsCollector performs thread-safe in-memory metrics aggregation.

func NewCollector

func NewCollector() *MetricsCollector

NewCollector creates a new MetricsCollector.

func (*MetricsCollector) RecordTokenUsage

func (c *MetricsCollector) RecordTokenUsage(usage TokenUsage)

RecordTokenUsage records a token usage event.

func (*MetricsCollector) RecordToolExecution

func (c *MetricsCollector) RecordToolExecution(name, agentName string, duration time.Duration, success bool)

RecordToolExecution records a tool execution event.

func (*MetricsCollector) Reset

func (c *MetricsCollector) Reset()

Reset clears all collected metrics.

func (*MetricsCollector) SessionMetrics

func (c *MetricsCollector) SessionMetrics(sessionKey string) *SessionMetric

SessionMetrics returns metrics for a specific session, or nil if not found.

func (*MetricsCollector) Snapshot

func (c *MetricsCollector) Snapshot() SystemSnapshot

Snapshot returns a point-in-time copy of all metrics.

func (*MetricsCollector) TopSessions

func (c *MetricsCollector) TopSessions(limit int) []SessionMetric

TopSessions returns the top N sessions by total tokens.

type SessionMetric

type SessionMetric struct {
	SessionKey   string
	InputTokens  int64
	OutputTokens int64
	TotalTokens  int64
	RequestCount int64
}

SessionMetric aggregates metrics for a single session.

type SystemSnapshot

type SystemSnapshot struct {
	StartedAt        time.Time
	Uptime           time.Duration
	TokenUsageTotal  TokenUsageSummary
	ToolExecutions   int64
	ToolBreakdown    map[string]ToolMetric
	AgentBreakdown   map[string]AgentMetric
	SessionBreakdown map[string]SessionMetric
}

SystemSnapshot is a point-in-time summary of system metrics.

type TokenUsage

type TokenUsage struct {
	Provider     string
	Model        string
	SessionKey   string
	AgentName    string
	InputTokens  int64
	OutputTokens int64
	TotalTokens  int64
	CacheTokens  int64
	Timestamp    time.Time
}

TokenUsage records a single token usage event.

type TokenUsageSummary

type TokenUsageSummary struct {
	InputTokens  int64
	OutputTokens int64
	TotalTokens  int64
	CacheTokens  int64
}

TokenUsageSummary aggregates token counts across all providers/models.

type ToolMetric

type ToolMetric struct {
	Name          string
	Count         int64
	Errors        int64
	TotalDuration time.Duration
	AvgDuration   time.Duration
}

ToolMetric aggregates metrics for a single tool.

Directories

Path Synopsis
Package audit records events to the existing AuditLog Ent schema.
Package audit records events to the existing AuditLog Ent schema.

Jump to

Keyboard shortcuts

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