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) ClearIQClipRatio(system string)
- func (m *Metrics) ClearIQDCRatioDb(system string)
- func (m *Metrics) ClearIQPowerDbFS(system string)
- func (m *Metrics) ClearWidebandInput(serial string)
- func (m *Metrics) Close() error
- func (m *Metrics) Handler() http.Handler
- func (m *Metrics) RecordDecodeError(protocol, stage string)
- func (m *Metrics) RecordDecodeOverrun()
- func (m *Metrics) RecordIQClipRatio(system string, ratio float64)
- func (m *Metrics) RecordIQDCRatioDb(system string, ratioDb float64)
- func (m *Metrics) RecordIQPowerDbFS(system string, dbfs float64)
- func (m *Metrics) RecordIQUnderrun(driver, serial string)
- func (m *Metrics) RecordTetraViterbiCorrections(system, channel string, corrections int)
- func (m *Metrics) RecordUSBReconnect(driver, serial string)
- func (m *Metrics) RecordWidebandInputClipRatio(serial string, ratio float64)
- func (m *Metrics) RecordWidebandInputPowerDbFS(serial string, dbfs float64)
- 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.
detailedFEC opts into the per-protocol FEC correction-depth histograms (today: gophertrunk_tetra_viterbi_corrections). They are off by default so a stock deployment doesn't carry a histogram family whose buckets only make sense to an operator profiling on-air recovery margins.
func (*Metrics) ClearIQClipRatio ¶ added in v0.3.1
ClearIQClipRatio drops the clip-ratio gauge series for system. Called alongside ClearIQPowerDbFS when a decoder pipeline tears down.
func (*Metrics) ClearIQDCRatioDb ¶ added in v0.2.5
ClearIQDCRatioDb drops the DC-ratio gauge series for system. Called alongside ClearIQPowerDbFS when a decoder pipeline tears down.
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) ClearWidebandInput ¶ added in v0.5.0
ClearWidebandInput drops both whole-capture gauge series for a dongle. Called when the wideband engine tears down.
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) RecordDecodeOverrun ¶ added in v0.3.1
func (m *Metrics) RecordDecodeOverrun()
RecordDecodeOverrun increments the decode-overrun counter: one live IQ chunk dropped at the decode queue because decode can't keep up with real time (issue #402). Distinct from RecordIQUnderrun, which is the SDR driver's own delivery-channel overrun.
func (*Metrics) RecordIQClipRatio ¶ added in v0.3.1
RecordIQClipRatio sets the rail-clipping-fraction gauge for system. The decoder computes this once per IQ-power window; the metrics package just stores it. See iqClipRatio's Help text for interpretation (issue #402).
func (*Metrics) RecordIQDCRatioDb ¶ added in v0.2.5
RecordIQDCRatioDb sets the DC-bin-to-total IQ power ratio gauge for system. The decoder computes this once per IQ-power window; the metrics package just stores it. See iqDCRatioDb's Help text for interpretation guidance (issue #402).
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) RecordTetraViterbiCorrections ¶ added in v0.4.2
RecordTetraViterbiCorrections observes one TETRA §8.3.1 FEC correction-depth sample (channel bits the decode chain corrected on a recovered burst) for the given system + logical channel. No-op unless metrics.detailed_fec enabled the histogram (the common case), so the connector can wire it unconditionally without a gate of its own.
func (*Metrics) RecordUSBReconnect ¶
RecordUSBReconnect increments the reconnect counter for the supplied SDR.
func (*Metrics) RecordWidebandInputClipRatio ¶ added in v0.5.0
RecordWidebandInputClipRatio sets the whole-capture clip-ratio gauge for a wideband dongle (issue #749).
func (*Metrics) RecordWidebandInputPowerDbFS ¶ added in v0.5.0
RecordWidebandInputPowerDbFS sets the whole-capture power gauge for a wideband dongle (issue #749).
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.