Skip to content

Feat/data readings - #150

Draft
lawik wants to merge 2 commits into
mainfrom
feat/data-readings
Draft

Feat/data readings#150
lawik wants to merge 2 commits into
mainfrom
feat/data-readings

Conversation

@lawik

@lawik lawik commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

ReportServer was the cursor left behind when the remote reporter went in
v0.6.0: one in-memory mark per instance, advanced on every read whoever
the reader was and whatever they did with the result. Nothing in Mobius
used it, and it is the wrong shape for shipping data anywhere. A cursor
is a fact about the destination's copy, so it belongs to the consumer,
one per sink, advanced only once a send is accepted, and persisted on
the consumer's cadence rather than Mobius's.

Mobius.get_latest_metrics/1 and get_latest_events/1 go with it. The
replacement is a window query (Mobius.Data.metrics/4, EventLog.list/1
with :from/:to) driven by a cursor the caller keeps.
Mobius keeps cumulative state at uneven density: a scrape a second for
two minutes, then one a minute, then one an hour, and each scrape lives
in exactly one archive, so no archive is a complete timeline and the
merge of all four is. Anything shipping that history to a remote system
has had to know all of this, plus how to turn a cumulative counter or a
summary accumulator into a number that means something on its own.

readings/1 does that work once, as a pure function of the stored
scrapes. It thins the merged timeline to the earliest scrape per step
(nothing is averaged; gauges sub-sample, the cumulative types delta
exactly), and reduces every type to plain numbers: last_value as is,
counter and sum as the rate since the previous reading, summary as the
average/std_dev/reports of the observations since the previous reading,
histograms as quantiles of the same delta. Tags fold into the name, and
a :key function renames or drops series. The result is an ascending
list of %{timestamp:, metrics: %{name => number}}, which is what a
remote metrics API wants and what a per-step threshold can judge.

The window options are the cursor: a reporter asks for everything after
the last second it shipped and advances that mark only once the send is
accepted. Mobius does not keep the mark; see the previous commit.

Scraper.snapshots/2 returns records and histogram payloads from the same
scrapes in one call, so deltas between consecutive scrapes cannot be
split by a scrape landing between two calls.

The README's remote-reporting section still described the :remote_reporter
option removed in v0.6.0; it now describes this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant