telemetry

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package telemetry provides the minimal metrics set for tool calls: a call counter labeled by tool and outcome, a per-tool duration histogram, and an audit-drop counter, served in Prometheus text exposition format. It is dependency-free by design; hosts that need a full metrics stack can mount their own handler instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogHooks

func LogHooks(logger *slog.Logger) *hook.Hooks

LogHooks returns hooks that emit one structured log line per tool failure, carrying the decision ID so log lines correlate with the MCP response, the audit event, and the trace span of the same call.

func Outcome

func Outcome(err error) string

Outcome classifies a tool error as a stable metric label: "" error is OK, governed rejections use their Denial code, infrastructure rejections use dedicated values, and everything else is INTERNAL (details stay in logs).

Types

type Metrics

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

Metrics is a concurrency-safe collector plus http.Handler. The zero value is not usable; construct with NewMetrics.

func NewMetrics

func NewMetrics() *Metrics

NewMetrics returns an empty collector.

func (*Metrics) Hooks

func (m *Metrics) Hooks() *hook.Hooks

Hooks returns lifecycle hooks that record one counter increment and one duration observation per tool call. Compose with other hooks via hook.Join.

func (*Metrics) ServeHTTP

func (m *Metrics) ServeHTTP(w http.ResponseWriter, _ *http.Request)

ServeHTTP writes the Prometheus text exposition format. Output is sorted so scrapes are deterministic.

func (*Metrics) SetAuditDropped

func (m *Metrics) SetAuditDropped(read func() int64)

SetAuditDropped installs a live reader for the audit drop counter (e.g. audit.AsyncAuditor.Dropped), sampled at scrape time.

Jump to

Keyboard shortcuts

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