telemetry

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package telemetry tracks lightweight in-memory, per-provider counters so /admin/status can report what the gateway has been doing without needing an external metrics backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProviderStats

type ProviderStats struct {
	Requests         int64   `json:"requests"`
	Failures         int64   `json:"failures"`
	PromptTokens     int64   `json:"prompt_tokens"`
	CompletionTokens int64   `json:"completion_tokens"`
	AvgLatencyMS     int64   `json:"avg_latency_ms"`
	SuccessRate      float64 `json:"success_rate"`
}

ProviderStats is a point-in-time snapshot of one provider's counters.

type Registry

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

Registry aggregates counters per provider ID.

func New

func New() *Registry

New creates an empty telemetry registry.

func (*Registry) RecordAttempt

func (r *Registry) RecordAttempt(id string)

RecordAttempt increments the request counter for a provider.

func (*Registry) RecordFailure

func (r *Registry) RecordFailure(id string)

RecordFailure increments the failure counter for a provider.

func (*Registry) RecordLatency

func (r *Registry) RecordLatency(id string, ms int64)

RecordLatency folds one attempt's wall-clock duration into the running average shown in /admin/status.

func (*Registry) RecordUsage

func (r *Registry) RecordUsage(id string, promptTokens, completionTokens int)

RecordUsage adds prompt/completion token counts for a provider.

func (*Registry) Snapshot

func (r *Registry) Snapshot() map[string]ProviderStats

Snapshot returns a copy of all providers' current stats, keyed by ID.

Jump to

Keyboard shortcuts

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