Documentation
¶
Overview ¶
Package metrics exposes a Prometheus collector for GopherTrunk.
The `Metrics` type owns a private prometheus.Registry, registers a set of counters / gauges, and runs a goroutine that subscribes to the internal events bus and increments counters as engine events flow by. Subsystems (SDR pool, protocol decoders, recorder) push their own metrics through the public Record* methods.
The handler is exposed via Handler() so cmd/gophertrunk can mount it at /metrics on the API server.
Index ¶
- Variables
- type Metrics
- func (m *Metrics) ClearIQPowerDbFS(system string)
- func (m *Metrics) Close() error
- func (m *Metrics) Handler() http.Handler
- func (m *Metrics) RecordDecodeError(protocol, stage string)
- func (m *Metrics) RecordIQPowerDbFS(system string, dbfs float64)
- func (m *Metrics) RecordIQUnderrun(driver, serial string)
- func (m *Metrics) RecordUSBReconnect(driver, serial string)
- func (m *Metrics) Registry() *prometheus.Registry
- func (m *Metrics) Run(ctx context.Context) error
- func (m *Metrics) SetSDRAttached(driver, serial, role string, attached bool)
- type Snapshotter
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyRegistered = errors.New("metrics: collector already registered")
ErrAlreadyRegistered is returned by New when the supplied registry already has a collector with the same descriptor (used in tests).
Functions ¶
This section is empty.
Types ¶
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics owns the Prometheus registry and counters/gauges used by the daemon.
func New ¶
New constructs the metrics registry and (optionally) subscribes to the supplied events bus. Pass nil for the bus to use the metrics package purely for the manual Record* methods. Pass nil for pool to skip the SDR snapshot collector.
func (*Metrics) ClearIQPowerDbFS ¶ added in v0.1.7
ClearIQPowerDbFS drops the gauge series for system. Called when a decoder pipeline tears down so stale dBFS values don't linger after the SDR is no longer being driven for that system.
func (*Metrics) Handler ¶
Handler returns an http.Handler that serves the registered metrics. Mount this at /metrics on the API server.
func (*Metrics) RecordDecodeError ¶
RecordDecodeError increments the per-protocol/stage decode-error counter.
func (*Metrics) RecordIQPowerDbFS ¶ added in v0.1.7
RecordIQPowerDbFS sets the mean-IQ-power gauge for system. Caller computes the window mean; the metrics package just stores it.
func (*Metrics) RecordIQUnderrun ¶
RecordIQUnderrun increments the underrun counter for the supplied SDR.
func (*Metrics) RecordUSBReconnect ¶
RecordUSBReconnect increments the reconnect counter for the supplied SDR.
func (*Metrics) Registry ¶
func (m *Metrics) Registry() *prometheus.Registry
Registry returns the underlying registry. Tests use it to scrape individual counters.
func (*Metrics) Run ¶
Run consumes events from the subscription until ctx cancels. Returns nil when the subscription closed before ctx, ctx.Err() otherwise. Safe to call without a bus configured (returns immediately).
func (*Metrics) SetSDRAttached ¶
SetSDRAttached toggles the attached-gauge for a device.
type Snapshotter ¶ added in v0.1.7
Snapshotter is the subset of sdr.Pool the snapshot collector needs. Declared here (rather than imported from sdr) so callers can pass a nil Pool or a fake without dragging in the full sdr.Pool surface.