The problem
In version 0.3 its instances shared S3 input through split coordination, where a leader cut the input into splits and leased them out over a NATS store. The lease and commit logic was hard to keep correct, with 14 defects still open when it was deprecated, and it slowed as hosts were added.
Like a manager who divides a pile of paperwork between staff and logs every hand-over in a shared ledger.
// Spate 0.3, simplified. Each highlighted line is a fenced write to the
// shared store, so two instances never commit the same split.
for split in list(prefix).chunks(split_size) {
store.write_fenced(lease(split, instance))?;
}
// On the instance holding the split, while it reads, then once it is done
store.write_fenced(renewal(split))?;
store.write_fenced(commit(split))?;
Version 0.4 replaces it with a work feed, a queue of work units that a source reads through. A worker receives a unit, renews it while it holds it, then settles it by acknowledging it, failing it or handing it back.
Closer to a shared tray, where each person takes the next item and an item nobody finishes goes back in the tray.
// Spate 0.4, simplified from the S3 source, on Spate's Feed trait.
for delivery in feed.receive(units_free)? {
read(&delivery);
feed.renew(delivery.receipt)?; // while it reads
feed.acknowledge(delivery.receipt)?; // or fail, or hand_back on a stop
}
// No call waits on the network. The backend talks to SQS or Kafka in the background.
The coordination metrics go when the crate is removed, and no feed backend exported any in their place. An operator could not see how many units a worker held, how fast units settled, how often a renewal found its unit gone or how long feed calls took. The metrics had to land first.
What I changed
- Wrapped the feed in the runtime.
MeteredFeedforwards every call to the backend and records receives, renewals, settles, hand-backs and publishes. One wrapper covers every backend, so the in-process, SQS and Kafka feeds report the same families with no change to any of them. - Counted publishes with a settle hook. A hook on
Confirmationrecords the publish when it settles, so no task runs per publish. - Added the
spate_feed_*families. There are counters for units received, acknowledged, failed, handed back, renewed and published, a gauge for units held, an error counter and two duration histograms.opanderror_typetake values from fixed enums. - Reserved
feedas a metric root.Meter::with_namespace("feed", …)now panics where it worked before, so the change is marked breaking. - Documented the families.
docs/METRICS.mdlists them, and the scaling-out guide points operators to them.
Every call goes through one helper, which times it and counts any error.
// crates/spate-core/src/feed/metered.rs
fn call<T>(
&self,
op: FeedOp,
call: impl FnOnce() -> Result<T, FeedError>,
) -> Result<T, FeedError> {
let watch = Stopwatch::start(&*self.clock);
let result = call();
self.metrics.call(op, watch.elapsed(&*self.clock));
if let Err(e) = &result {
self.metrics.error(op, e.kind);
}
result
}
Tests pin that each call reaches the backend once and returns its answer, that the held gauge is claimed once per pipeline, and that a running pipeline counts what its source does.
Seeing it work
I ran two workers on one queue, against local stand-ins for S3 and SQS, with Prometheus, Loki and Grafana watching. Then I broke things on purpose. I shortened the lease from 60s to 15s and slowed the sink so each case plays out in seconds. The diagrams show what happens to the work, and the numbers come from that run.
A worker dies
I killed one worker with no chance to drain. Its units stayed hidden until their lease ran out, then
went back to the queue for the other worker. spate_feed_held_units showed the survivor rise from
about 2.5 units to its cap of 8, and its settle rate from 0.8 to 1.4 units a second. A worker I
froze for 30 seconds instead came back to 8 renewals refused as gone, one for each unit the queue
had handed on.
A poisoned unit
I sent the queue a message that is not a storage notification, then a notification for an object
that does not exist. The workers failed each one back, and the queue moved each to its dead-letter
queue on the fifth delivery. spate_feed_units_failed_total rose by 10, the dead-letter gauge from
#1515 read 2, and the settle rate did not dip.
A poisoned record
A bad line inside a good object is a different failure. The deserialiser skipped it and counted it
under spate_deser_records_total{outcome="error"}, and the unit was acknowledged as normal. The
feed families stayed quiet, which tells an operator the queue is not the place to look.
The sink goes down
For 40 seconds every write to the sink failed. Each worker kept renewing the 8 units it held, so the
queue gave none of them away, and new work waited in the queue. The sink retried about 18 writes, settling
fell almost to zero and no renewal came back gone. When the sink returned, the held units were
written and acknowledged.

What the feed metrics don’t show
Freezing the queue or the object store for 30 seconds moved no spate_feed_* error. Feed calls
never wait on the network, so a short outage behind them shows only as slower settling. The queue
freeze changed nothing visible, and the store freeze halved the settle rate.
Judgement calls
I reused existing labels and error series instead of adding new ones. The issue proposed a
backend label and a counter for units gone after a refused renewal. I dropped both.
component_type already carries the backend key, so a backend label would repeat it on every
series. A refused renewal already appears as
spate_feed_errors_total{op="renew",error_type="gone"}, so a second counter would count the same
event twice. The issue marked its metric names as illustrative.
I split the issue across three pull requests. The issue also asked for a Meter for each
backend. That went to #1516 and the dead-letter depth to #1515, so this change holds only the
wrapper and its families. The hand_back call arrived after the issue was written, so I added
spate_feed_units_handed_back_total for it.
I left calls made through a handle the caller keeps from Pipeline::feed uncounted, because the
runtime wraps only the feed it hands the source. The metrics reference says so.
What review changed
The review found three behaviours that no test pinned. For each they showed a one-line change that still passed all 607 tests. A publish the backend dropped was not checked as a retryable error, the feed was not checked against the injected clock, and publish call time was not checked at all. I added a test for each.
The review also asked for the Pipeline::feed rustdoc and the Kafka and SQS feed pages to mention
the new families. I added those and fixed two guides with the same gap. I skipped one assertion in
the suggested test, because the error count already fails when either code path changes.
Outcome
Merged on 30 October 2026, the morning after it was opened. It gave feeds metrics before the coordination crate’s removal, and is the first of three pull requests for #1196.