telemetry

package
v0.1.125 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package telemetry gives every app /metrics (Prometheus exposition, OpenTelemetry-compatible), /healthz (liveness) and /readyz (readiness: every service that can check itself is asked). Request metrics are labelled by route pattern, never by raw path, so cardinality stays bounded.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Healthz

func Healthz() http.Handler

Healthz is liveness: the process serves requests.

Types

type Named

type Named interface {
	Name() string
}

Named services label their stats; otherwise the Go type name is used.

type Ready

type Ready interface {
	Ready(ctx context.Context) error
}

Ready is implemented by services that can report readiness: a database pool that pings, a bus that is connected. /readyz fails while any returns an error.

type Stats

type Stats interface {
	TelemetryStats() map[string]float64
}

Stats is implemented by services that expose gauges: pool sizes, open connections, calls in flight. Keys are metric-safe names.

type Telemetry

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

Telemetry is the registry and the collectors of one app.

func New

func New(each func(func(any))) *Telemetry

New builds a registry with the Go runtime and process collectors, the request metrics and a collector that walks services (each is called with every registered service).

func (*Telemetry) Metrics

func (t *Telemetry) Metrics() http.Handler

Metrics serves the Prometheus exposition.

func (*Telemetry) Middleware

func (t *Telemetry) Middleware() func(http.Handler) http.Handler

Middleware records every request. Place it directly around the router so the matched pattern (http.Request.Pattern) is visible.

func (*Telemetry) Readyz

func (t *Telemetry) Readyz(timeout time.Duration) http.Handler

Readyz asks every Ready service, with a deadline, and replies 503 while any fails. The body lists each check.

func (*Telemetry) Registry

func (t *Telemetry) Registry() *prometheus.Registry

Registry exposes the registry for packs that add their own metrics.

Jump to

Keyboard shortcuts

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