metrics

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package metrics exports jargo's service measurements — time-to-first-byte, processing time, LLM token usage and TTS characters — as OpenTelemetry metrics over OTLP. It is the aggregate, fleet-level counterpart to the per-turn frames.MetricsFrame the services emit in-band (and the RTVI metrics messages the client sees).

The service processors record through the global meter, so instrumentation costs nothing until a MeterProvider is installed. Call Init at startup to export over OTLP; an OpenTelemetry Collector forwards the metrics to Prometheus or any other backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(ctx context.Context, cfg Config) (func(context.Context) error, error)

Init installs a global MeterProvider that periodically exports to an OTLP HTTP collector, and returns a shutdown function that flushes and stops it. Call the returned function on exit. The service processors begin recording as soon as the provider is installed.

func RecordProcessing

func RecordProcessing(ctx context.Context, kind, service, model string, seconds float64)

RecordProcessing records a service's processing time, in seconds.

func RecordTTFB

func RecordTTFB(ctx context.Context, kind, service, model string, seconds float64)

RecordTTFB records a service's time to first byte, in seconds.

func RecordTTSCharacters

func RecordTTSCharacters(ctx context.Context, service string, n int64)

RecordTTSCharacters records the number of characters a TTS service synthesized.

func RecordTokens

func RecordTokens(ctx context.Context, service, model string, input, output int64)

RecordTokens records LLM token usage, split by direction (input/output).

Types

type Config

type Config struct {
	// ServiceName labels the metrics; defaults to "jargo".
	ServiceName string
	// ServiceVersion is an optional version label.
	ServiceVersion string
	// Endpoint overrides the OTLP HTTP endpoint (host:port). Empty honors the
	// standard OTEL_EXPORTER_OTLP_ENDPOINT environment variable.
	Endpoint string
	// Insecure sends over plain HTTP instead of HTTPS.
	Insecure bool
}

Config configures OTLP metric export.

Jump to

Keyboard shortcuts

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