Files
unpoller_unpoller/pkg/poller
Cody LeeandClaude Opus 5 3d178bed8d fix: AppendMetrics silently dropped SpeedTests and the batch timestamp
AppendMetrics merges every slice field on Metrics except SpeedTests, so
speed test results were discarded on the way from the input to the
outputs. Both call sites start from a non-nil &Metrics{}, so this hit
every user on every poll: inputunifi collected the results, and the
export code in promunifi, influxunifi and datadogunifi was dead.

TS was dropped the same way. The aggregate starts bare and nothing
restored the timestamp, so it stayed zero -- and influxunifi's collect()
stamps any point that carries no timestamp of its own with the
aggregate's, which meant the zero time. Both Influx clients omit a zero
timestamp and let the server assign one, so the damage was limited to
points being stamped on arrival rather than at poll time, but it made
the fallback path meaningless. First writer wins: the earliest input's
timestamp is the one that describes the batch.

The failure mode here is what makes it worth guarding rather than just
patching. A new metric family needs a field on Metrics and an append
line in AppendMetrics, and omitting the second loses every metric in
that family with no error, no log line, and a passing build.
TestAppendMetricsCoversEverySliceField walks the struct by reflection
and fails naming any slice field that is not merged, so a new field is
covered the moment it is declared rather than when someone notices the
graphs are empty.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 07:59:04 -05:00
..
2022-12-02 20:48:01 -05:00
2022-12-03 16:32:12 -06:00
2022-12-03 16:32:12 -06:00

poller

UniFi Poller Core

This module ties the inputs together with the outputs.

Aggregates metrics on request. Provides CLI app and args parsing.

Ideal

This library has no notion of "UniFi" or controllers, or Influx, or Prometheus. This library simply provides an input interface and an output interface. Each interface uses an []any type, so any type of data can be used. That is to say, you could write input and output plugins that work with, say, Cisco gear, or any other network (or even non-network) data. The existing plugins should provide ample example of how to use this library, but at some point the godoc will improve.

Features

  • Automatically unmarshal's plugin config structs from config file and/or env variables.
  • Initializes all "imported" plugins on startup.
  • Provides input plugins a Logger, requires an interface for Metrics and Events retrieval.
  • Provides Output plugins an interface to retrieve Metrics and Events, and a Logger.
  • Provides automatic aggregation of Metrics and Events from multiple sources.