telemetry

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package telemetry provides cache-hit metrics for Grafana and OTel integration (N09). Lightweight in-memory instruments support testing without a collector and can be replaced with OTel SDK instruments. Metrics are omnix.cache.hit_ratio (histogram by session/preset/turn), omnix.cache.hit_tokens, omnix.cache.miss_tokens, and omnix.cache.broken_count (incremented for detected cache-breaking patterns).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MetricsNames

func MetricsNames() []string

MetricsNames returns the four exported metric names for OTel and dashboard integration.

Types

type CacheMetrics

type CacheMetrics struct {
	HitRatios       []float64 // Cache-hit ratio samples for the histogram.
	HitTokensTotal  int64
	MissTokensTotal int64
	BrokenCount     int64

	// Session label for the current aggregation.
	SessionID string
	Preset    string
	TurnSeq   int
	// contains filtered or unexported fields
}

CacheMetrics aggregates cache-hit metrics.

func NewCacheMetrics

func NewCacheMetrics() *CacheMetrics

NewCacheMetrics creates a metrics aggregator.

func (*CacheMetrics) HistogramP50

func (m *CacheMetrics) HistogramP50() float64

HistogramP50 returns the median cache-hit ratio for the hit_ratio_p50 Grafana alert.

func (*CacheMetrics) MarkBroken

func (m *CacheMetrics) MarkBroken()

MarkBroken increments the cache-breaking event counter.

func (*CacheMetrics) Record

func (m *CacheMetrics) Record(hit, miss int, ratio float64)

Record records cache metrics for one request.

Jump to

Keyboard shortcuts

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