Documentation
¶
Overview ¶
Package metrics provides Prometheus-format metrics collection and export.
Index ¶
- type Counter
- type Gauge
- type Histogram
- type OTLPExporter
- type Registry
- func (r *Registry) AddTokens(provider string, count int64)
- func (r *Registry) Counter(name, help string) *Counter
- func (r *Registry) Gauge(name, help string) *Gauge
- func (r *Registry) Handler() http.Handler
- func (r *Registry) Histogram(name, help string, buckets []float64) *Histogram
- func (r *Registry) IncAgentRuns(agentID string)
- func (r *Registry) IncErrors(tenant, kind string)
- func (r *Registry) IncToolCalls(toolName string)
- func (r *Registry) ObserveModelLatency(provider string, d time.Duration)
- func (r *Registry) RecordModelCall(tenant, provider string, d time.Duration, promptTokens, completionTokens int64, ...)
- func (r *Registry) RecordToolCall(tenant, tool string, d time.Duration, isErr bool)
- func (r *Registry) SetActiveSessions(n float64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a monotonically increasing metric.
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge is a metric that can go up and down.
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
Histogram tracks value distributions in configurable buckets. It keeps an unlabeled default series plus any number of labeled series (used for per-tenant / per-provider attribution).
type OTLPExporter ¶ added in v0.4.0
type OTLPExporter struct {
// contains filtered or unexported fields
}
OTLPExporter exports the registry's metrics to an OTLP/HTTP endpoint using the JSON encoding of the OpenTelemetry metrics protocol (ExportMetricsServiceRequest). When the endpoint is empty it is a no-op, so offline runs and tests never require a live collector.
func NewOTLPExporter ¶ added in v0.4.0
func NewOTLPExporter(endpoint string) *OTLPExporter
NewOTLPExporter creates a metrics exporter. endpoint should be the collector base URL (e.g. "http://localhost:4318"); the exporter POSTs to "<endpoint>/v1/metrics". An empty endpoint yields a no-op exporter.
func (*OTLPExporter) Enabled ¶ added in v0.4.0
func (e *OTLPExporter) Enabled() bool
Enabled reports whether the exporter will actually export.
func (*OTLPExporter) Export ¶ added in v0.4.0
func (e *OTLPExporter) Export(ctx context.Context, r *Registry) error
Export snapshots the registry and sends it to the configured endpoint. When disabled (empty endpoint) it returns nil without doing any I/O.
func (*OTLPExporter) WithHTTPClient ¶ added in v0.4.0
func (e *OTLPExporter) WithHTTPClient(c *http.Client) *OTLPExporter
WithHTTPClient overrides the HTTP client (useful for tests).
func (*OTLPExporter) WithHeader ¶ added in v0.4.0
func (e *OTLPExporter) WithHeader(k, v string) *OTLPExporter
WithHeader adds a header sent with each export request (e.g. auth).
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all Chronos metrics and serves them in Prometheus format.
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry creates a new metrics registry with pre-defined Chronos metrics.
func (*Registry) Handler ¶
Handler returns an http.Handler that serves metrics in Prometheus format.
func (*Registry) IncAgentRuns ¶
IncAgentRuns increments the agent runs counter.
func (*Registry) IncErrors ¶ added in v0.4.0
IncErrors increments the error counter for a tenant and error kind.
func (*Registry) IncToolCalls ¶
IncToolCalls increments the tool calls counter.
func (*Registry) ObserveModelLatency ¶
ObserveModelLatency records a model call latency.
func (*Registry) RecordModelCall ¶ added in v0.4.0
func (r *Registry) RecordModelCall(tenant, provider string, d time.Duration, promptTokens, completionTokens int64, isErr bool)
RecordModelCall records a single model invocation with per-tenant attribution: model-call counter, token usage (prompt + completion), latency, and errors.
func (*Registry) RecordToolCall ¶ added in v0.4.0
RecordToolCall records a single tool invocation with per-tenant attribution: it increments the tool-call counter, observes latency, and increments the error counter when the call failed.
func (*Registry) SetActiveSessions ¶
SetActiveSessions sets the active session count.