Documentation
¶
Overview ¶
Package observe is the in-process metrics + JSONL dumping layer shared by the controller, relay, and agent. The surface is deliberately minimal — Counter, Gauge, Histogram, plus a Registry that owns named instances. No external observability stack (Prometheus, OpenTelemetry) is pulled in: the project ships a JSONL dump (Dumper) and a localhost-only debug endpoint (DebugMux) so operators can collect data without running a TSDB.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultDurationBounds = []time.Duration{ time.Microsecond, 10 * time.Microsecond, 100 * time.Microsecond, time.Millisecond, 10 * time.Millisecond, 100 * time.Millisecond, time.Second, 10 * time.Second, }
DefaultDurationBounds covers ~10ns through 10s in roughly decade steps; it's the default for histograms that observe a duration.
Functions ¶
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a monotonically increasing int64.
type Dumper ¶
type Dumper struct {
// contains filtered or unexported fields
}
Dumper periodically writes a Snapshot of the Registry as one JSON line to a file. Each line is self-contained, so downstream tooling (e.g. `tools/correlate`, a notebook) can stream the file without holding state across lines.
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge is a freely-mutable int64 (concurrent stream count, RSS, etc).
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
Histogram is a bucketed observation distribution. Buckets are open-bottom, closed-top: counts[i] holds observations <= bounds[i], counts[len(bounds)] is the overflow ("> bounds[last]") bucket.
func NewHistogram ¶
NewHistogram constructs a histogram. If bounds is empty, DefaultDurationBounds is used.
func (*Histogram) Quantile ¶
Quantile estimates the value at q (0 < q < 1) via linear bucket interpolation. Returns 0 if there are no observations.
func (*Histogram) Snapshot ¶
func (h *Histogram) Snapshot() HistogramSnapshot
Snapshot copies counter values; cheap.
type HistogramSnapshot ¶
type HistogramSnapshot struct {
Bounds []time.Duration `json:"bounds_ns"`
Counts []int64 `json:"counts"`
SumNs int64 `json:"sum_ns"`
N int64 `json:"n"`
}
HistogramSnapshot is a point-in-time view used by dumpers / HTTP.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry owns named metrics. It is goroutine-safe and the same instance is shared across server constructors.