metrics

package
v1.0.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalStore = NewMemoryStore()

Functions

This section is empty.

Types

type DailyStats

type DailyStats struct {
	ReqCount            int64   `json:"req_count"`
	InputTokens         int64   `json:"input_tokens"`
	OutputTokens        int64   `json:"output_tokens"`
	CachedTokens        int64   `json:"cached_tokens"`
	CacheCreationTokens int64   `json:"cache_creation_tokens"`
	Cost                float64 `json:"cost"`
}

type EndpointMinutePerf added in v0.9.0

type EndpointMinutePerf struct {
	// Provider-only observations keep attempts separate from legacy requests.
	UpstreamSuccess        int64
	UpstreamFailure        int64
	RequestSamples         int64
	LegacyProviderRequests int64
	Requests               int64
	Success                int64
	Fail                   int64
	InputTokens            int64
	OutputTokens           int64
	Output                 int64
	Cost                   float64
	TTFTSum                int64
	TTFTCount              int64
	LatencySumMs           int64
	LatencyCount           int64
	DurationMs             int64
}

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func NewMemoryStoreAt added in v1.0.4

func NewMemoryStoreAt(start time.Time) *MemoryStore

NewMemoryStoreAt records the start of observation, distinct from retention.

func (*MemoryStore) AggregateGlobalMinutePerf added in v0.9.4

func (s *MemoryStore) AggregateGlobalMinutePerf(startMinute, endMinute int64) EndpointMinutePerf

func (*MemoryStore) AggregateModelMinutePerf added in v0.9.4

func (s *MemoryStore) AggregateModelMinutePerf(modelCode string, startMinute, endMinute int64) EndpointMinutePerf

func (*MemoryStore) GetDailyStats

func (s *MemoryStore) GetDailyStats(dateStr string) DailyStats

func (*MemoryStore) GetEndpointIDs added in v0.9.6

func (s *MemoryStore) GetEndpointIDs() []string

func (*MemoryStore) GetEndpointMinutePerf added in v0.9.0

func (s *MemoryStore) GetEndpointMinutePerf(endpointID string, minute int64) EndpointMinutePerf

func (*MemoryStore) GetEndpointStatus

func (s *MemoryStore) GetEndpointStatus(endpointID string, minute int64) (int64, int64)

func (*MemoryStore) GetGlobalMinutePerf added in v0.9.4

func (s *MemoryStore) GetGlobalMinutePerf(minute int64) EndpointMinutePerf

func (*MemoryStore) GetGlobalStatus

func (s *MemoryStore) GetGlobalStatus(minute int64) (int64, int64)

func (*MemoryStore) GetModelCodes added in v0.9.4

func (s *MemoryStore) GetModelCodes() []string

func (*MemoryStore) GetModelEndpointIDs added in v0.9.6

func (s *MemoryStore) GetModelEndpointIDs(model string) []string

func (*MemoryStore) GetModelMinutePerf added in v0.9.0

func (s *MemoryStore) GetModelMinutePerf(modelCode string, minute int64) EndpointMinutePerf

func (*MemoryStore) GetModelStatus

func (s *MemoryStore) GetModelStatus(modelCode string, minute int64) (int64, int64)

func (*MemoryStore) GetOpenEndpoints

func (s *MemoryStore) GetOpenEndpoints() []string

func (*MemoryStore) GetOpenServices

func (s *MemoryStore) GetOpenServices() []string

func (*MemoryStore) GetProviderMinutePerf added in v0.9.4

func (s *MemoryStore) GetProviderMinutePerf(provider string, minute int64) EndpointMinutePerf

func (*MemoryStore) GetProviderNames added in v0.9.4

func (s *MemoryStore) GetProviderNames() []string

func (*MemoryStore) GetProviderStatus added in v0.9.4

func (s *MemoryStore) GetProviderStatus(provider string, minute int64) (int64, int64)

func (*MemoryStore) LookupProviderMinutePerf added in v1.0.4

func (s *MemoryStore) LookupProviderMinutePerf(provider string, startMinute, endMinute int64) (EndpointMinutePerf, bool)

LookupProviderMinutePerf distinguishes an observed zero from an absent identity.

func (*MemoryStore) Record

func (s *MemoryStore) Record(m RequestMetric)

func (*MemoryStore) StartedAt added in v1.0.4

func (s *MemoryStore) StartedAt() time.Time

func (*MemoryStore) UpdateCircuitBreakers

func (s *MemoryStore) UpdateCircuitBreakers(endpoints []string, services []string)

type RequestMetric

type RequestMetric struct {
	Time                int64   `json:"time"` // Unix timestamp
	Model               string  `json:"model"`
	Provider            string  `json:"provider,omitempty"`
	Success             bool    `json:"success"`
	InputTokens         int64   `json:"input_tokens"`
	OutputTokens        int64   `json:"output_tokens"`
	CachedTokens        int64   `json:"cached_tokens"`
	CacheCreationTokens int64   `json:"cache_creation_tokens"`
	Cost                float64 `json:"cost"`
	EndpointID          string  `json:"endpoint_id,omitempty"`
	TTFTMs              int64   `json:"ttft_ms,omitempty"`
	DurationMs          int64   `json:"duration_ms,omitempty"`
	Attempts            []struct {
		EndpointID   string `json:"endpoint_id"`
		Provider     string `json:"provider,omitempty"`
		ProviderCode string `json:"provider_code,omitempty"`
		Success      bool   `json:"success"`
	} `json:"attempts"`
}

Jump to

Keyboard shortcuts

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