observability

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Overview

Package observability exposes Chronos's runtime metrics in Prometheus exposition format. It is intentionally small — counters only, hand-rolled rendering, no external dependencies.

Two consumers feed the registry:

  • The pipeline package calls ObserveSignal whenever a detector emits and ObserveObservations whenever entity states are saved.
  • The HTTP middleware calls ObserveHTTP for every request once the response has been written.

The /metrics endpoint (mounted by internal/api) renders the current state in Prometheus text format. Operators wanting more sophisticated instrumentation (histograms, exemplars, OTLP) should front Chronos with a sidecar; this in-process implementation is the operational floor, not the ceiling.

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 is a thread-safe in-memory metrics registry. The zero value is unusable; construct with New.

func New

func New() *Metrics

New creates an empty registry.

func (*Metrics) ObserveHTTP

func (m *Metrics) ObserveHTTP(method string, status int, path string, dur time.Duration)

ObserveHTTP records the outcome of an HTTP request. method and status are coarse labels; path is included separately on the duration counters because high-cardinality paths can blow up label space and we keep the request count cardinality bounded.

func (*Metrics) ObserveObservations

func (m *Metrics) ObserveObservations(adapter string, n int)

ObserveObservations records that n observations were ingested from the named adapter.

func (*Metrics) ObserveSignal

func (m *Metrics) ObserveSignal(pattern string)

ObserveSignal records that one signal of the given pattern was emitted.

func (*Metrics) ObserveWebhook

func (m *Metrics) ObserveWebhook(outcome string, status int)

ObserveWebhook records the outcome of a single webhook delivery attempt. outcome is one of "success", "client_error", "failure"; status is the final HTTP status code observed (0 when the request never returned, e.g., DNS failure).

func (*Metrics) Render

func (m *Metrics) Render(w io.Writer) error

Render writes the registry as a Prometheus exposition document. Output is sorted within each family so diffs across scrapes stay stable.

Jump to

Keyboard shortcuts

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