Documentation
¶
Overview ¶
Package observability builds safe, bounded token-accounting observations for future metrics and logging adapters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Input ¶
type Input struct {
Labels Labels
Status Status
FallbackReason string
Err error
Duration time.Duration
OccurredAt time.Time
}
Input is the untrusted input used to build an Observation.
type Observation ¶
type Observation struct {
Labels Labels
Status Status
FallbackReason Reason
ErrorReason Reason
Duration time.Duration
OccurredAt time.Time
}
Observation is a content-free, sanitized count-attempt record.
func NewObservation ¶
func NewObservation(input Input) (Observation, error)
NewObservation validates labels, classifies unsafe details, and returns a bounded observation.
func (Observation) Attributes ¶
func (o Observation) Attributes() map[string]string
Attributes returns a bounded string map suitable for future metrics/logging adapters.
type Reason ¶
type Reason string
Reason is a bounded reason classification for fallback, unavailable, and error outcomes.
type Sink ¶
type Sink interface {
Record(Observation)
}
type Snapshot ¶
type Snapshot struct {
SourceSelections map[Source]int
FallbackReasons map[Reason]int
LatencyCount int
LatencySum time.Duration
Latencies []time.Duration
}
Snapshot is a point-in-time copy of accumulated observation stats.
type Source ¶
type Source string
Source identifies where a token count came from.
const ( SourceProviderReported Source = "provider_reported" SourceProviderCountAPI Source = "provider_count_api" SourceLocalTokenizer Source = "local_tokenizer" SourceAdministratorSupplied Source = "administrator_supplied" SourceTransformedRecomputed Source = "transformed_recomputed" SourceRequestScopedReuse Source = "request_scoped_reuse" )
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
Stats accumulates bounded token-accounting observability dimensions in memory.
func (*Stats) Record ¶
func (s *Stats) Record(obs Observation)
Record adds one validated observation to the accumulator.