telemetry

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DriverAvailable = true

DriverAvailable indicates whether the SQLite driver is compiled in.

Variables

This section is empty.

Functions

func DBPath

func DBPath(configPath string) string

DBPath resolves the tracking database path.

Types

type CommandRecord

type CommandRecord struct {
	OriginalCmd  string
	ScouterCmd   string
	InputTokens  int
	OutputTokens int
	SavedTokens  int
	SavingsPct   float64
	ExecTimeMs   int64
	Timestamp    string
}

CommandRecord holds a single tracked command.

type CommandStats

type CommandStats struct {
	Command      string
	Count        int
	InputTokens  int
	OutputTokens int
	SavedTokens  int
	AvgSavings   float64
}

CommandStats holds aggregate stats per command.

type DayStats

type DayStats struct {
	Day          string
	Commands     int
	InputTokens  int
	OutputTokens int
	SavedTokens  int
	AvgSavings   float64
}

DayStats holds daily tracking stats.

type PeriodStats

type PeriodStats struct {
	Period       string
	Commands     int
	InputTokens  int
	OutputTokens int
	SavedTokens  int
	AvgSavings   float64
}

PeriodStats holds aggregate stats for a time period (week or month).

type Summary

type Summary struct {
	TotalCommands int
	TotalSaved    int
	AvgSavings    float64
	TotalTimeMs   int64
}

Summary holds aggregate tracking stats.

type TimedExecution

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

TimedExecution tracks execution duration and delegates to Tracker.

func Start

func Start(tracker *Tracker) *TimedExecution

Start creates a new TimedExecution.

func (*TimedExecution) Track

func (te *TimedExecution) Track(ctx context.Context, originalCmd, scouterCmd string, inputTokens, outputTokens int) error

Track records a filtered command with elapsed duration.

func (*TimedExecution) TrackPassthrough

func (te *TimedExecution) TrackPassthrough(ctx context.Context, cmd string, tokens int) error

TrackPassthrough records a passthrough command with elapsed duration.

type Tracker

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

Tracker manages token savings tracking in SQLite.

func NewLazyTracker

func NewLazyTracker(dbPath string) *Tracker

NewLazyTracker creates a tracker that defers DB opening until first use.

func NewTracker

func NewTracker(ctx context.Context, dbPath string) (*Tracker, error)

NewTracker opens or creates a SQLite database for tracking (immediate open).

func (*Tracker) Close

func (t *Tracker) Close() error

Close closes the database connection.

func (*Tracker) GetByCommand

func (t *Tracker) GetByCommand(ctx context.Context, limit int) ([]CommandStats, error)

GetByCommand returns top N commands by tokens saved.

func (*Tracker) GetDaily

func (t *Tracker) GetDaily(ctx context.Context, days int) ([]DayStats, error)

GetDaily returns daily stats for the last N days.

func (*Tracker) GetMonthly

func (t *Tracker) GetMonthly(ctx context.Context, months int) ([]PeriodStats, error)

GetMonthly returns monthly stats for the last N months.

func (*Tracker) GetRecent

func (t *Tracker) GetRecent(ctx context.Context, n int) ([]CommandRecord, error)

GetRecent returns the last N tracked commands.

func (*Tracker) GetSummary

func (t *Tracker) GetSummary(ctx context.Context) (*Summary, error)

GetSummary returns aggregate tracking stats.

func (*Tracker) GetWeekly

func (t *Tracker) GetWeekly(ctx context.Context, weeks int) ([]PeriodStats, error)

GetWeekly returns weekly stats for the last N weeks.

func (*Tracker) Track

func (t *Tracker) Track(ctx context.Context, originalCmd, scouterCmd string, inputTokens, outputTokens int, execTimeMs int64) error

Track records a filtered command execution.

func (*Tracker) TrackPassthrough

func (t *Tracker) TrackPassthrough(ctx context.Context, cmd string, tokens int, execTimeMs int64) error

TrackPassthrough records a passthrough (unfiltered) command.

func (*Tracker) Wait

func (t *Tracker) Wait()

Wait waits for any background initialization to complete.

func (*Tracker) WarmUp

func (t *Tracker) WarmUp(ctx context.Context)

WarmUp starts opening the DB in the background. Call this before command execution so SQLite init overlaps with the command.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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