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 ¶
- func Init(ctx context.Context, cfg Config) (func(context.Context) error, error)
- func RecordProcessing(ctx context.Context, kind, service, model string, seconds float64)
- func RecordTTFB(ctx context.Context, kind, service, model string, seconds float64)
- func RecordTTSCharacters(ctx context.Context, service string, n int64)
- func RecordTokens(ctx context.Context, service, model string, input, output int64)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
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 ¶
RecordProcessing records a service's processing time, in seconds.
func RecordTTFB ¶
RecordTTFB records a service's time to first byte, in seconds.
func RecordTTSCharacters ¶
RecordTTSCharacters records the number of characters a TTS service synthesized.
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.