wire/frames/monitor.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4// Copyright (c) 2026 2youg1 and the sprawling contributors
5
6//! The performance monitor's pair of frames (`crates/wire/spec/Frames/Monitor.lean` §8-47g):
7//! whether a session is watching, and one reading sent to it.
8
9use serde::{Deserialize, Serialize};
10
11/// Whether this session counts as somebody watching the monitor.
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
13#[serde(rename_all = "snake_case")]
14#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
15pub enum Monitoring {
16 /// Watch the whole monitor page.
17 Watch,
18 /// Watch only the one-line summary beside the settings tree's performance entry, which reads this process alone.
19 WatchSummary,
20 Release,
21}
22
23/// What one watcher looks at, which decides how much the city reads for
24/// it. It does not travel: it is what `MonitorFeed::watch` is told.
25#[derive(Debug, Clone, Copy, PartialEq, Eq)]
26pub enum Watched {
27 Everything,
28 Summary,
29}
30
31/// One reading of every counter the monitor shows, in integers because
32/// it travels on the wire (`crates/sprawling/Spec.lean` §8-94, §8-129-6).
33#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
34#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
35pub struct Sample {
36 pub core_cpu_permille: u64,
37 pub core_private_bytes: u64,
38 pub core_working_set_bytes: u64,
39 pub core_read_bytes: u64,
40 pub core_written_bytes: u64,
41 pub machine_cpu_permille: u64,
42 pub machine_available_bytes: u64,
43 pub volume_free_bytes: u64,
44 pub ledger_queue_depth: u64,
45 pub durable_lag: u64,
46 pub relay_p50_nanos: u64,
47 pub event_to_screen_p50_nanos: u64,
48 pub queued_runs: u64,
49 /// Committed records the writer has handed the view thread that are
50 /// not yet folded and broadcast (`crates/sprawling/Spec.lean` §8-123).
51 pub view_backlog: u64,
52 /// How long the beat before this one took to read the counters, by
53 /// the sampler's own monotonic clock; 0 on the first beat
54 /// (`crates/sprawling/Spec.lean` §8-129-6).
55 pub read_nanos: u64,
56}