From 67b5c3ae079f9f524bf0c52521a62811da407ad0 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 9 Nov 2026 20:31:10 +0000 Subject: stats: the writers of the document How many writers (Automerge actors) the document's changes have matters: a writer is a node's run (each start, rejoin or drop makes one, a start keeping the one of before with `--keep-actor` after a clean stop), and every transfer of the whole history carries a signature for each. `/admin/stats` now says it (`document.writers`, and `document_writers` for Prometheus), counted from the changes' metadata alongside the saved size's measurement in the background (at least a minute apart), as that takes time proportional to the document too; an export, which measures the size alone, keeps the count of before. The dashboard's figures show it with the rest. --- src/document/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/document') diff --git a/src/document/mod.rs b/src/document/mod.rs index c183537..a546d63 100644 --- a/src/document/mod.rs +++ b/src/document/mod.rs @@ -13,6 +13,16 @@ pub(crate) use automerge::{ ScalarValue, }; +/// How many writers (actors) `doc`'s changes have: from the changes' metadata, in +/// time proportional to the document. +pub(crate) fn writers(doc: &Document) -> usize { + doc.get_changes_meta(&[]) + .into_iter() + .map(|meta| meta.actor.into_owned()) + .collect::>() + .len() +} + /// The whole document as bytes, as the engine saves it: a backup, the document /// file's full save, the size a joining node downloads. pub(crate) fn save(doc: &Document) -> Vec { -- cgit v1.3.1