metrics

package
v0.26.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package metrics owns Peen's application Prometheus registry and its bounded runtime collectors.

Index

Constants

View Source
const OutcomeCancelled = outcomeCancelled

OutcomeCancelled names an operation ended by cancellation.

View Source
const OutcomeError = outcomeError

OutcomeError names an operation which returned an error.

View Source
const OutcomeSuccess = outcomeSuccess

OutcomeSuccess names a completed operation without an error.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

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

Metrics is the application-owned Prometheus registry. Its methods accept only labels that Peen controls, never request, session, workspace, command, path, prompt, or SQL values.

func New

func New() *Metrics

New constructs one isolated application registry. It intentionally does not use Prometheus's global registry, so tests and embedding programs cannot leak collectors into each other.

func (*Metrics) Collect added in v0.22.0

func (m *Metrics) Collect(values chan<- prometheus.Metric)

Collect forwards current values without using Prometheus's global registry.

func (*Metrics) DatabaseCompleted

func (m *Metrics) DatabaseCompleted(
	operation string,
	table string,
	outcome string,
	duration time.Duration,
)

DatabaseCompleted records one GORM operation. table is reduced to Peen's fixed schema vocabulary before becoming a label.

func (*Metrics) DatabasePool

func (m *Metrics) DatabasePool(stats sql.DBStats)

DatabasePool records a point-in-time SQLite pool snapshot.

func (*Metrics) Describe added in v0.22.0

func (m *Metrics) Describe(descriptions chan<- *prometheus.Desc)

Describe exposes the owned collectors to an embedding caller's registry.

func (*Metrics) EventDropped

func (m *Metrics) EventDropped(reason string)

EventDropped records a durable pending-event or live-subscriber drop.

func (*Metrics) HTTPCompleted

func (m *Metrics) HTTPCompleted(
	method string,
	route string,
	status string,
	outcome string,
	duration time.Duration,
)

HTTPCompleted records one public HTTP request and removes it from the in-flight gauge. route must be Echo's templated route, never a raw URL.

func (*Metrics) HTTPStarted

func (m *Metrics) HTTPStarted()

HTTPStarted marks one public HTTP request in flight.

func (*Metrics) Handler

func (m *Metrics) Handler() http.Handler

Handler returns the OpenMetrics text-compatible Prometheus scrape handler.

func (*Metrics) JobCompleted

func (m *Metrics) JobCompleted(
	operation string,
	outcome string,
	duration time.Duration,
)

JobCompleted records one supervised process result and removes it from the active-job gauge.

func (*Metrics) JobOutputDropped

func (m *Metrics) JobOutputDropped(stream string, count int)

JobOutputDropped records lines discarded from a completed job's bounded stdout or stderr buffer.

func (*Metrics) JobStarted

func (m *Metrics) JobStarted()

JobStarted increments the number of supervised process jobs currently live.

func (*Metrics) ModelCompleted

func (m *Metrics) ModelCompleted(
	stage string,
	function string,
	model string,
	outcome string,
	duration time.Duration,
	timeToFirstToken time.Duration,
	inputTokens int64,
	outputTokens int64,
)

ModelCompleted records one whole Elelem request. input and output counts are the request's final run totals, already accumulated by Elelem across rounds.

func (*Metrics) Registry

func (m *Metrics) Registry() *prometheus.Registry

Registry returns the registry owned by this Metrics instance.

func (*Metrics) ToolCompleted

func (m *Metrics) ToolCompleted(
	tool string,
	outcome string,
	duration time.Duration,
)

ToolCompleted records one host tool invocation.

type Server

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

Server exposes a Metrics registry on an operator-owned listener. It is intentionally separate from Peen's public API router.

func NewServer

func NewServer(metrics *Metrics) (*Server, error)

NewServer constructs a scraper-only HTTP server without opening a listener.

func (*Server) ServeListener

func (s *Server) ServeListener(
	ctx context.Context,
	listener net.Listener,
) error

ServeListener serves the scraper endpoint until the service context ends.

Jump to

Keyboard shortcuts

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