observability

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package observability supplies process-local Prometheus registries and safe transport observations. Labels passed here must come from fixed operations or registered inventory, never request paths, credentials, or error messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func App

func App(r *http.Request, identity Identity)

func Bool

func Bool(value bool) float64

func ETH

func ETH(value *big.Rat) float64

func ErrorKind

func ErrorKind(err error) string

ErrorKind deliberately discards remote and transport error text.

func Operation

func Operation(r *http.Request, operation string)

func Outcome

func Outcome(r *http.Request, outcome string)

func Stream

func Stream(r *http.Request, identity Identity, protocol string)

func TrackResponse

func TrackResponse(r *http.Request, response *http.Response)

TrackResponse preserves upgraded bodies and observes failures after headers.

Types

type Emit

type Emit func(name string, value float64, labels Labels)

type Identity

type Identity struct{ App, AppID, Runner, Mode string }

func (Identity) Labels

func (i Identity) Labels() Labels

type Labels

type Labels map[string]string

func (Labels) With

func (l Labels) With(key, value string) Labels

type Metrics

type Metrics struct {
	Registry  *prometheus.Registry
	Component string
	// contains filtered or unexported fields
}

Metrics owns a registry; services and tests never share global collectors. Families are registered on first use, with a fixed label schema thereafter.

func New

func New(component string) *Metrics

func (*Metrics) Add

func (m *Metrics) Add(name string, value float64, labels Labels)

func (*Metrics) Discovery

func (m *Metrics) Discovery(source int, elapsed time.Duration, err error)

func (*Metrics) Gauge

func (m *Metrics) Gauge(name string, labels Labels) prometheus.Gauge

func (*Metrics) HTTP

func (m *Metrics) HTTP(w http.ResponseWriter, r *http.Request, serve http.HandlerFunc)

HTTP observes the entire handler lifetime, including upgraded connections. httpsnoop preserves the exact optional ResponseWriter interfaces.

func (*Metrics) Handler

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

func (*Metrics) Legacy

func (m *Metrics) Legacy(collect func(Emit))

func (*Metrics) Observe

func (m *Metrics) Observe(name string, value float64, labels Labels)

func (*Metrics) PaymentObserver

func (m *Metrics) PaymentObserver(o *eth.PaymentObserver, logger *slog.Logger)

PaymentObserver collects authoritative memory-only state. The callback only remembers the last logged health transition; it does not decide freshness.

func (*Metrics) RPC

func (m *Metrics) RPC(o eth.RPCObservation)

Contract/refresh metrics adapt Mike Zupper's BlueClawNetwork/livepeer-node internal/observability/metrics.go at 2c2ce3cf8a51f5464ce4961bbb6c2e640f348ae0 (MIT; see LICENSE).

func (*Metrics) Snapshot

func (m *Metrics) Snapshot(collect func(Emit))

Snapshot registers read-only collection. Callbacks must bound database reads and must not make network requests or mutate business state.

type Request

type Request struct {
	Operation string
	Identity  Identity
	App       bool
	Protocol  string
	Outcome   string
	// contains filtered or unexported fields
}

func State

func State(r *http.Request) *Request

Jump to

Keyboard shortcuts

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