metrics

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package metrics owns chatz's Prometheus registry and the per-subsystem metric vectors. It is constructed once at boot (no package globals) and passed to the recorders that emit; the /metrics handler and the pprof mux are served on internal-only ports (never the public ingress).

Index

Constants

View Source
const (
	TokenKindInput  = "input"
	TokenKindOutput = "output"
	TokenKindCache  = "cache_read"
)

Token kinds for the llm_tokens_total counter.

View Source
const (
	OutcomeOK    = "ok"
	OutcomeError = "error"
)

Outcomes for request counters (bounded set).

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

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

Metrics holds the registry and the metric vectors. Emit via the Record* methods; expose via Handler / PprofHandler.

func New

func New() (*Metrics, error)

New builds the registry, registers the runtime + build-info collectors and the subsystem vectors, and returns the Metrics.

func (*Metrics) Handler

func (m *Metrics) Handler() http.Handler

Handler serves the Prometheus exposition for the registry.

func (*Metrics) PprofHandler

func (m *Metrics) PprofHandler() http.Handler

PprofHandler returns a mux with the net/http/pprof endpoints under /debug/pprof/. Internal-only: never mount on the public ingress.

func (*Metrics) RecordLLMRequest

func (m *Metrics) RecordLLMRequest(
	service, stage, model, outcome string,
	dur time.Duration,
)

RecordLLMRequest records one LLM call's latency + count under the outcome.

func (*Metrics) RecordLLMTokens

func (m *Metrics) RecordLLMTokens(
	service, stage, model, kind string,
	n int64,
)

RecordLLMTokens adds token counts for a call, by kind.

Jump to

Keyboard shortcuts

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