usage

package
v0.0.0-...-28f0a9b Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentSpend

type AgentSpend struct {
	Agent string  `json:"agent"`
	Spend float64 `json:"spend_usd"`
}

type ModelSpend

type ModelSpend struct {
	Model string  `json:"model"`
	Spend float64 `json:"spend_usd"`
}

type PostgresStore

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

func NewPostgresStore

func NewPostgresStore(db *pgxpool.Pool) *PostgresStore

func (*PostgresStore) GetSpendByAgent

func (s *PostgresStore) GetSpendByAgent(ctx context.Context, from, to time.Time) ([]AgentSpend, error)

func (*PostgresStore) GetSpendByModel

func (s *PostgresStore) GetSpendByModel(ctx context.Context, from, to time.Time) ([]ModelSpend, error)

func (*PostgresStore) GetSpendByProject

func (s *PostgresStore) GetSpendByProject(ctx context.Context, from, to time.Time) ([]ProjectSpend, error)

func (*PostgresStore) GetSpendByProvider

func (s *PostgresStore) GetSpendByProvider(ctx context.Context, from, to time.Time) ([]ProviderSpend, error)

func (*PostgresStore) GetSpendByTeam

func (s *PostgresStore) GetSpendByTeam(ctx context.Context, from, to time.Time) ([]TeamSpend, error)

func (*PostgresStore) GetSpendForAgent

func (s *PostgresStore) GetSpendForAgent(ctx context.Context, agent string, from, to time.Time) (float64, error)

func (*PostgresStore) GetSpendForProject

func (s *PostgresStore) GetSpendForProject(ctx context.Context, project string, from, to time.Time) (float64, error)

func (*PostgresStore) GetSpendForTeam

func (s *PostgresStore) GetSpendForTeam(ctx context.Context, team string, from, to time.Time) (float64, error)

func (*PostgresStore) GetTotalSpend

func (s *PostgresStore) GetTotalSpend(ctx context.Context, from, to time.Time) (float64, error)

func (*PostgresStore) Save

func (s *PostgresStore) Save(ctx context.Context, r Record) error

type ProjectSpend

type ProjectSpend struct {
	Project string  `json:"project"`
	Spend   float64 `json:"spend_usd"`
}

type ProviderSpend

type ProviderSpend struct {
	Provider string  `json:"provider"`
	Spend    float64 `json:"spend_usd"`
}

type Record

type Record struct {
	RequestID         string
	Timestamp         time.Time
	Provider          string
	Model             string
	PromptTokens      int
	CompletionTokens  int
	TotalTokens       int
	EstimatedCostUSD  float64
	PriceFound        bool
	CacheHit          bool
	MeteringEstimated bool
	Team              string
	Project           string
	User              string
	Agent             string
	Path              string
	StatusCode        int
}

type Store

type Store interface {
	Save(ctx context.Context, record Record) error
	GetTotalSpend(ctx context.Context, from, to time.Time) (float64, error)
	GetSpendByTeam(ctx context.Context, from, to time.Time) ([]TeamSpend, error)
	GetSpendByProvider(ctx context.Context, from, to time.Time) ([]ProviderSpend, error)
	GetSpendByModel(ctx context.Context, from, to time.Time) ([]ModelSpend, error)
	GetSpendByProject(ctx context.Context, from, to time.Time) ([]ProjectSpend, error)
	GetSpendForTeam(ctx context.Context, team string, from, to time.Time) (float64, error)
	GetSpendForProject(ctx context.Context, project string, from, to time.Time) (float64, error)
	GetSpendForAgent(ctx context.Context, agent string, from, to time.Time) (float64, error)
	GetSpendByAgent(ctx context.Context, from, to time.Time) ([]AgentSpend, error)
}

type Summary

type Summary struct {
	From          time.Time `json:"from"`
	To            time.Time `json:"to"`
	TotalSpendUSD float64   `json:"total_spend_usd"`
}

type TeamSpend

type TeamSpend struct {
	Team  string  `json:"team"`
	Spend float64 `json:"spend_usd"`
}

Jump to

Keyboard shortcuts

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