metrics

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package metrics owns the Prometheus registry and the collectors exposed at GET /v0/metrics (Phase 2). It provides a chi-compatible middleware that records per-request count + duration keyed by route *pattern* (never the raw path, to keep label cardinality bounded) and a hook the events path calls to report ingest counts. promhttp renders the exposition format — we never hand-format Prometheus text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

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

Metrics holds a private registry and the TinyRaven collectors. Use New to build one; the zero value is not usable.

func New

func New() *Metrics

New builds a Metrics with its own registry and registers all collectors. A dedicated registry (not the global default) keeps tests isolated and avoids duplicate-registration panics when several instances coexist.

func (*Metrics) Handler

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

Handler serves the metrics exposition format from this instance's registry. Mount it at /v0/metrics.

func (*Metrics) IngestObserved

func (m *Metrics) IngestObserved(success, quarantined int)

IngestObserved reports ingest outcomes from the events path (orchestrator calls it after gatherer.Ingest returns its counts).

func (*Metrics) Middleware

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

Middleware records request count + duration + status per route. Labels use the chi route *pattern* (e.g. "/v0/pipes/{name}.json"), resolved after the handler runs since chi fills the RouteContext during ServeHTTP. Pipe routes (those with a "name" URL param) also increment the per-pipe counter.

Jump to

Keyboard shortcuts

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