Documentation
¶
Overview ¶
Package metrics implements an in-process metrics sink for the rysh agentic system. It satisfies rysh-shared/agentic.MetricsSink and exposes a simple text dump usable from `##agent metrics`.
Follow-up item 3, MVP form: in-memory aggregation. A Prometheus exporter is a natural drop-in via the same interface (add a PrometheusSink that wraps client_golang's Registry); kept out of this commit to avoid pulling in a new dependency.
Prometheus exporter for the agentic MetricsSink (follow-up 3b).
PromSink is a drop-in MetricsSink that records into a private prometheus.Registry; the daemon serves it on /metrics behind the metrics config flag. It composes with the in-process Sink via Multi so ##agent metrics keeps working alongside scraping.
Index ¶
- type Multi
- func (m *Multi) Dump() string
- func (m *Multi) RecordApproval(toolName, decision string, dur time.Duration)
- func (m *Multi) RecordCompaction(droppedTurns int, dur time.Duration)
- func (m *Multi) RecordLLMCall(model string, dur time.Duration, usage provider.Usage)
- func (m *Multi) RecordTool(name string, dur time.Duration, out *sharedtools.ToolOutput, err error)
- type PromSink
- func (p *PromSink) Handler() http.Handler
- func (p *PromSink) RecordApproval(toolName, decision string, dur time.Duration)
- func (p *PromSink) RecordCompaction(droppedTurns int, dur time.Duration)
- func (p *PromSink) RecordLLMCall(model string, dur time.Duration, usage provider.Usage)
- func (p *PromSink) RecordTool(name string, dur time.Duration, out *sharedtools.ToolOutput, err error)
- type Sink
- func (s *Sink) Dump() string
- func (s *Sink) RecordApproval(toolName, decision string, dur time.Duration)
- func (s *Sink) RecordCompaction(droppedTurns int, dur time.Duration)
- func (s *Sink) RecordLLMCall(model string, dur time.Duration, usage provider.Usage)
- func (s *Sink) RecordTool(name string, dur time.Duration, out *sharedtools.ToolOutput, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Multi ¶
type Multi struct {
// contains filtered or unexported fields
}
Multi fans every MetricsSink call out to several sinks (e.g. the in-process Sink for ##agent metrics plus a PromSink for scraping). It exposes Dump() by delegating to a designated dumper (the in-process Sink), so the existing ##agent metrics command keeps working when Prometheus is enabled.
func NewMulti ¶
func NewMulti(primary *Sink, extra ...sharedagentic.MetricsSink) *Multi
NewMulti builds a fan-out. primary (the in-process Sink) is always first and is used for Dump(); extra sinks are appended. primary may be nil.
func (*Multi) RecordApproval ¶
RecordApproval implements sharedagentic.MetricsSink.
func (*Multi) RecordCompaction ¶
RecordCompaction implements sharedagentic.MetricsSink.
func (*Multi) RecordLLMCall ¶
RecordLLMCall implements sharedagentic.MetricsSink.
func (*Multi) RecordTool ¶
func (m *Multi) RecordTool(name string, dur time.Duration, out *sharedtools.ToolOutput, err error)
RecordTool implements sharedagentic.MetricsSink.
type PromSink ¶
type PromSink struct {
// contains filtered or unexported fields
}
PromSink implements sharedagentic.MetricsSink by recording into a private Prometheus registry. Use Handler() to serve it. Safe for concurrent use (Prometheus collectors are internally synchronised).
func NewPrometheus ¶
func NewPrometheus() *PromSink
NewPrometheus builds a PromSink with all collectors registered into a fresh private registry (no global state; the /metrics output is rysh-only).
func (*PromSink) Handler ¶
Handler returns an http.Handler that serves this sink's registry in Prometheus text format.
func (*PromSink) RecordApproval ¶
RecordApproval implements sharedagentic.MetricsSink.
func (*PromSink) RecordCompaction ¶
RecordCompaction implements sharedagentic.MetricsSink.
func (*PromSink) RecordLLMCall ¶
RecordLLMCall implements sharedagentic.MetricsSink.
func (*PromSink) RecordTool ¶
func (p *PromSink) RecordTool(name string, dur time.Duration, out *sharedtools.ToolOutput, err error)
RecordTool implements sharedagentic.MetricsSink.
type Sink ¶
type Sink struct {
// contains filtered or unexported fields
}
Sink is an in-process MetricsSink. Safe for concurrent use.
func (*Sink) Dump ¶
Dump returns a human-readable text summary of accumulated metrics. Used by the `##agent metrics` command.
func (*Sink) RecordApproval ¶
RecordApproval implements agentic.MetricsSink.
func (*Sink) RecordCompaction ¶
RecordCompaction implements agentic.MetricsSink.
func (*Sink) RecordLLMCall ¶
RecordLLMCall implements agentic.MetricsSink.
func (*Sink) RecordTool ¶
func (s *Sink) RecordTool(name string, dur time.Duration, out *sharedtools.ToolOutput, err error)
RecordTool implements agentic.MetricsSink.