modem-mgmt 0.2.0

The management plane of zenoh-modem as a library: serve every device on a host over Zenoh, for any driver that links the contract
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
//! Counters, published as `telemetry`.
//!
//! Everything here already existed as an atomic somewhere in the driver; this
//! is a publisher over data, not a new collection path. What the management
//! plane adds is that the numbers leave the process.
//!
//! Class semantics matter (zenkey RFC 04 §1): `telemetry` is superseded — a
//! missed sample is replaced by the next, and a delete is never sent. That is
//! the right class for monotonic counters and a queue depth, and it is why
//! these ride the `sampled` QoS profile: best-effort, droppable, data-low. A
//! counter that blocked the bus to deliver a sample nobody will read is worse
//! than a counter that skipped one.
//!
//! **The metric names live in `registry/modem.toml` and nowhere else.** This
//! module used to keep a `&[&str]` beside it, concatenate keys as strings, and
//! end its dispatch with `unreachable!("unregistered metric")` — three ways for
//! the code and the contract to disagree. `zenkey-build` generates a `Subject`
//! enum from that registry, carrying the key builder and the declared QoS
//! profile, so two of the three are now impossible to write: a counter this
//! module publishes is a counter the registry declares, by construction, and
//! its key and QoS come from the declaration rather than from beside it.
//!
//! The third — a declared subject this module quietly stops publishing — is
//! **not** caught by the compiler, because `READINGS` is a list and not a
//! match. `tests::every_subject_published_is_one_the_registry_declares`
//! compares the two sets, and is the only thing standing between here and a
//! registry that lies by omission.
//!
//! **A fourth used to exist and no longer does**: publishing the right set of
//! names with the wrong numbers behind them. Names and values lived in two
//! parallel lists zipped by index, and this comment claimed a test read the
//! counters off the wire and checked them against the driver. None did (#100),
//! so a transposition among ten integers would have passed CI and produced a
//! dashboard that was confidently wrong — worse than one that is missing. The
//! two lists are now one table with the name beside its own reading, and
//! `tests::each_counter_carries_its_own_reading` drives a distinct sentinel
//! into every one of the readings and checks where each lands.

use std::sync::Arc;
use std::time::Duration;

use zenkey::origin::LocalOrigin;
use zenoh::Session;

use crate::plane::SduPlane;
use modem_contract::registry::modem::Subject;

/// How often counters are published, when a config does not say.
///
/// Five seconds is what §4.6 costs its argument in: twenty readings at this
/// cadence is 4 publications a second, which is why both shipped routers deny
/// the management plane on the radio. It is a default rather than a law — see
/// `MgmtConfig::telemetry_interval_ms`.
pub const DEFAULT_INTERVAL: Duration = Duration::from_millis(5_000);

/// Everything a reading can be taken from, sampled once.
///
/// Read into plain values up front so the table below is a list of field
/// accesses rather than a list of atomic loads: two readings of the same
/// counter inside one publish tick would otherwise be able to disagree.
struct Snapshot {
    /// The medium's and the scheduler's counters — `None` for a device that
    /// has no SDU plane (#118): a netdev has no lanes, no scheduler and no
    /// medium, and a counter it does not have is absent, never zero (#115).
    sdu: Option<SduCounters>,
    device: modem_device::Report,
    /// The kernel's counters, for a netdev (#130).
    netdev: Option<modem_device::NetdevStats>,
}

/// What the SDU plane counts.
struct SduCounters {
    medium: modem_device::Metrics,
    sched_dropped: u64,
    sched_stale: u64,
    sched_peerless: u64,
    tx_failed: u64,
    unroutable: u64,
    rx_oversize: u64,
    tx_oversize: u64,
    queue_depth: u64,
}

impl Snapshot {
    fn of(plane: &dyn SduPlane) -> Self {
        let s = plane.scheduler();
        Self {
            sdu: Some(SduCounters {
                medium: plane.medium_metrics(),
                sched_dropped: s.dropped,
                sched_stale: s.stale,
                sched_peerless: s.peerless,
                tx_failed: s.tx_failed,
                unroutable: s.unroutable,
                rx_oversize: s.rx_oversize,
                tx_oversize: s.tx_oversize,
                queue_depth: s.queue_depth(),
            }),
            device: plane.report(),
            netdev: None,
        }
    }

    /// A device with no SDU plane: only what it reports about itself.
    fn of_device(dev: &dyn modem_device::Device) -> Self {
        Self {
            sdu: None,
            device: dev.report(),
            netdev: None,
        }
    }

    fn of_netdev(dev: &dyn modem_device::Netdev) -> Self {
        Self {
            sdu: None,
            device: dev.report(),
            netdev: Some(dev.statistics()),
        }
    }

    /// The SDU plane's counters, when the device has one.
    fn sdu(&self) -> Option<&SduCounters> {
        self.sdu.as_ref()
    }
}

/// Which plane a telemetry loop reads (#118).
pub enum Source {
    /// An SDU device: the scheduler's counters and its medium's.
    Sdu(Arc<dyn SduPlane>),
    /// A device with no SDU plane: its own report, nothing else.
    Device(Arc<dyn modem_device::Device>),
    /// A device whose data plane is the kernel's (#130): a plain device with
    /// the interface's counters beside it.
    Netdev(Arc<dyn modem_device::Netdev>),
}

impl Source {
    /// The source for a node, whatever moves its bytes.
    pub(crate) fn of(node: &crate::host::Node) -> Self {
        match node.plane() {
            crate::host::Plane::Sdu(plane) => Self::Sdu(plane.clone()),
            crate::host::Plane::Netdev(dev) => Self::Netdev(dev.clone()),
        }
    }

    fn snapshot(&self) -> Snapshot {
        match self {
            Source::Sdu(p) => Snapshot::of(p.as_ref()),
            Source::Device(d) => Snapshot::of_device(d.as_ref()),
            Source::Netdev(n) => Snapshot::of_netdev(n.as_ref()),
        }
    }

    fn has_configuration(&self) -> bool {
        match self {
            Source::Sdu(p) => p.configuration().is_some(),
            Source::Device(d) => d.configuration().is_some(),
            Source::Netdev(n) => n.configuration().is_some(),
        }
    }

    fn has_actions(&self) -> bool {
        match self {
            Source::Sdu(p) => p.actions().is_some(),
            Source::Device(d) => d.actions().is_some(),
            Source::Netdev(n) => n.actions().is_some(),
        }
    }

    fn has_netdev(&self) -> bool {
        matches!(self, Source::Netdev(_))
    }
}

/// The `capability:` predicates that hold for this device, now — the
/// instance surface of RFC 08 §6.1's `when`, published per device in
/// `state/modem/sensor` (zenkey RFC 04 §5, v1.41; #122).
///
/// Derived from the same table the publish loop reads, so it cannot
/// disagree with what is on the wire: a reading that has a value is one
/// whose gate holds, and the gate's name comes from the registry entry
/// (`Subject::when`) rather than from a second list here. `sdu` holds for a
/// device with a lane driver, `config` for one that declares a
/// configuration plane.
pub(crate) fn capabilities_of(device: &str, source: &Source) -> std::collections::BTreeSet<String> {
    let snapshot = source.snapshot();
    let mut holds = std::collections::BTreeSet::new();
    if matches!(source, Source::Sdu(_)) {
        holds.insert("sdu".to_string());
    }
    if source.has_configuration() {
        holds.insert("config".to_string());
    }
    if source.has_actions() {
        holds.insert("actions".to_string());
    }
    if source.has_netdev() {
        holds.insert("netdev".to_string());
    }
    for (subject, value) in READINGS {
        if value(&snapshot).is_none() {
            continue;
        }
        for (kind, name) in subject(device).when() {
            if matches!(kind, zenkey::slice::PredicateKind::Capability) {
                holds.insert((*name).to_string());
            }
        }
    }
    holds
}

/// How old a gauge may be and still be published as current (#115).
///
/// Ten minutes: longer than any shipped poll interval — an SBD terminal reads
/// its signal every 60 s — and shorter than the hour-long lease a tuned
/// satellite link runs on, so a terminal that has stopped answering goes quiet
/// here before its transport notices. `Report::age_ms` is the device's
/// own statement of how old its snapshot is; a device that answers from live
/// atomics reports 0 and never expires.
pub const STALE_AFTER: Duration = Duration::from_secs(600);

impl Snapshot {
    /// Whether the device's snapshot is older than a gauge may be.
    fn stale(&self) -> bool {
        self.device
            .age_ms
            .is_some_and(|age| age > STALE_AFTER.as_millis() as u64)
    }

    /// The duty cycle, unless the snapshot it came from has expired.
    fn fresh_duty(&self) -> Option<modem_device::DutyCycle> {
        if self.stale() {
            None
        } else {
            self.device.duty_cycle
        }
    }

    /// The signal, unless the snapshot it came from has expired.
    /// A gauge, unless the report is stale (#115): a value the device has
    /// not refreshed in ten minutes is not a value.
    fn fresh<T: Copy>(&self, v: Option<T>) -> Option<T> {
        if self.stale() { None } else { v }
    }

    fn fresh_signal(&self) -> Option<u8> {
        if self.stale() {
            None
        } else {
            self.device.signal_bars
        }
    }
}

/// A counter: the subject that names it, beside the reading it publishes —
/// or, this tick, does not.
/// A published value: an integer for a counter or an integer gauge, a real
/// for a measurement (#123). One JSON number either way, and a `Measure`'s
/// real is the registry's unit — the report carries milli-units so that it
/// can stay `Copy + Eq`, and the conversion happens here, once.
#[derive(Clone, Copy, Debug, PartialEq)]
#[non_exhaustive]
pub enum Value {
    /// A `Counter` or a `Gauge`.
    Int(u64),
    /// A `Measure`, in the registry's unit.
    Real(f64),
}

impl Value {
    /// A fixed-point milli-unit reading, as the real it stands for.
    fn milli(m: i32) -> Self {
        Self::Real(f64::from(m) / 1000.0)
    }
}

impl std::fmt::Display for Value {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Int(v) => write!(f, "{v}"),
            Self::Real(v) => write!(f, "{v}"),
        }
    }
}

type Reading = (fn(&str) -> Subject, fn(&Snapshot) -> Option<Value>);

/// Every counter this producer publishes, in the order it publishes them.
///
/// **The one place a metric is named, and the one place its value is chosen.**
/// This module used to keep a `&[&str]` beside the dispatch that read it; the
/// names then came from the `Subject` enum `zenkey-build` generates out of
/// `registry/modem.toml`, so a counter that is not in the registry cannot be
/// spelled here at all — but the *values* still lived in a second list forty
/// lines away, zipped by index. A length mismatch was caught; a transposition
/// was not, and the comment claiming otherwise named a test that did not exist
/// (#100). Thirty-odd entries in one column and as many in another is a
/// counting exercise nobody should have to do correctly, so the name and the
/// number are on the same line and there is nothing left to mis-align.
///
/// `pub` reaches [`subjects`] rather than this table, because the router ACLs
/// have to be checked against the subject list without a running `Driver`.
const READINGS: &[Reading] = &[
    // The SDU plane's counters: absent for a device that has no such plane
    // (#118), because a netdev did not drop zero batches — it had none.
    (
        |d| Subject::device_sdu_tx_sdus_total(d),
        |s| (s.sdu().map(|c| c.medium.tx_sdus)).map(Value::Int),
    ),
    (
        |d| Subject::device_sdu_tx_bytes_total(d),
        |s| (s.sdu().map(|c| c.medium.tx_bytes)).map(Value::Int),
    ),
    (
        |d| Subject::device_sdu_rx_sdus_total(d),
        |s| (s.sdu().map(|c| c.medium.rx_sdus)).map(Value::Int),
    ),
    (
        |d| Subject::device_sdu_rx_bytes_total(d),
        |s| (s.sdu().map(|c| c.medium.rx_bytes)).map(Value::Int),
    ),
    (
        |d| Subject::device_sdu_dropped_total(d),
        |s| (s.sdu().map(|c| c.medium.dropped)).map(Value::Int),
    ),
    (
        |d| Subject::device_sched_dropped_total(d),
        |s| (s.sdu().map(|c| c.sched_dropped)).map(Value::Int),
    ),
    (
        |d| Subject::device_sched_stale_total(d),
        |s| (s.sdu().map(|c| c.sched_stale)).map(Value::Int),
    ),
    (
        |d| Subject::device_sched_peerless_total(d),
        |s| (s.sdu().map(|c| c.sched_peerless)).map(Value::Int),
    ),
    (
        |d| Subject::device_sdu_tx_failed_total(d),
        |s| (s.sdu().map(|c| c.tx_failed)).map(Value::Int),
    ),
    (
        |d| Subject::device_sdu_rx_unroutable_total(d),
        |s| (s.sdu().map(|c| c.unroutable)).map(Value::Int),
    ),
    (
        |d| Subject::device_sdu_rx_oversize_total(d),
        |s| (s.sdu().map(|c| c.rx_oversize)).map(Value::Int),
    ),
    (
        |d| Subject::device_sdu_tx_oversize_total(d),
        |s| (s.sdu().map(|c| c.tx_oversize)).map(Value::Int),
    ),
    // A device that does not know answers `None`, and `None` is **not
    // published** (#115). It used to go out as zero, on the argument that a
    // gap in a superseded series is indistinguishable from a slow publisher.
    // But a zero is a *reading* — on Iridium's scale it is "no signal" — and
    // zenkey RFC 08 §6.1 is unambiguous that a sentinel corrupts every
    // consumer downstream. Silence is the honest answer; the registry's ledger
    // says which subjects may be silent and why, and #124 makes the reason
    // per device once zenkey carries it.
    (
        |d| Subject::device_air_airtime_ms_total(d),
        |s| (s.device.time_on_air_ms).map(Value::Int),
    ),
    (
        |d| Subject::device_air_retransmits_total(d),
        |s| (s.device.retransmits).map(Value::Int),
    ),
    (
        |d| Subject::device_air_bytes_wasted_total(d),
        |s| (s.device.bytes_wasted).map(Value::Int),
    ),
    (
        |d| Subject::device_air_rx_errors_total(d),
        |s| (s.device.rx_errors).map(Value::Int),
    ),
    // The gauges also expire: a report older than `STALE_AFTER` describes a
    // device that has stopped answering, which is exactly when an operator is
    // reading it — `Report::age_ms`'s own rule, unimplemented until
    // #115. Counters do not expire: a cumulative figure stays true after the
    // device goes quiet.
    (
        |d| Subject::device_air_duty_cycle_available(d),
        |s| (s.fresh_duty().map(|c| u64::from(c.available))).map(Value::Int),
    ),
    (
        |d| Subject::device_air_duty_cycle_wait_ms(d),
        |s| (s.fresh_duty().map(|c| c.next_available_in_ms)).map(Value::Int),
    ),
    (
        |d| Subject::device_radio_signal_bars(d),
        |s| (s.fresh_signal().map(u64::from)).map(Value::Int),
    ),
    (
        |d| Subject::device_sched_queue_depth(d),
        |s| (s.sdu().map(|c| c.queue_depth)).map(Value::Int),
    ),
    // --- The IP-bearer vocabulary (#123): every one a gauge, every one
    // gated on the device measuring it, every one subject to the stale rule.
    (
        |d| Subject::device_radio_rssi(d),
        |s| s.fresh(s.device.rssi).map(Value::milli),
    ),
    (
        |d| Subject::device_radio_rsrp(d),
        |s| s.fresh(s.device.rsrp).map(Value::milli),
    ),
    (
        |d| Subject::device_radio_rsrq(d),
        |s| s.fresh(s.device.rsrq).map(Value::milli),
    ),
    (
        |d| Subject::device_radio_snr(d),
        |s| s.fresh(s.device.snr).map(Value::milli),
    ),
    (
        |d| Subject::device_radio_error_rate(d),
        |s| s.fresh(s.device.error_rate).map(Value::milli),
    ),
    (
        |d| Subject::device_link_rx_rate(d),
        |s| s.fresh(s.device.rx_rate).map(Value::Int),
    ),
    (
        |d| Subject::device_link_tx_rate(d),
        |s| s.fresh(s.device.tx_rate).map(Value::Int),
    ),
    (
        |d| Subject::device_link_rx_max_rate(d),
        |s| s.fresh(s.device.rx_max_rate).map(Value::Int),
    ),
    (
        |d| Subject::device_link_tx_max_rate(d),
        |s| s.fresh(s.device.tx_max_rate).map(Value::Int),
    ),
    (
        |d| Subject::device_link_latency(d),
        |s| s.fresh(s.device.latency).map(Value::Int),
    ),
    (
        |d| Subject::device_link_resources(d),
        |s| s.fresh(s.device.resources).map(Value::milli),
    ),
    (
        |d| Subject::device_link_rx_quality(d),
        |s| s.fresh(s.device.rx_quality).map(Value::milli),
    ),
    (
        |d| Subject::device_link_tx_quality(d),
        |s| s.fresh(s.device.tx_quality).map(Value::milli),
    ),
    // --- The kernel's interface counters (#130): a netdev's, exact RFC 8343
    // mappings where Linux keeps one, the two packet counters labelled as
    // not RFC 8343 in the registry.
    (
        |d| Subject::device_if_in_octets(d),
        |s| s.netdev.and_then(|n| n.in_octets).map(Value::Int),
    ),
    (
        |d| Subject::device_if_out_octets(d),
        |s| s.netdev.and_then(|n| n.out_octets).map(Value::Int),
    ),
    (
        |d| Subject::device_if_in_errors(d),
        |s| s.netdev.and_then(|n| n.in_errors).map(Value::Int),
    ),
    (
        |d| Subject::device_if_out_errors(d),
        |s| s.netdev.and_then(|n| n.out_errors).map(Value::Int),
    ),
    (
        |d| Subject::device_if_in_discards(d),
        |s| s.netdev.and_then(|n| n.in_discards).map(Value::Int),
    ),
    (
        |d| Subject::device_if_out_discards(d),
        |s| s.netdev.and_then(|n| n.out_discards).map(Value::Int),
    ),
    (
        |d| Subject::device_if_in_multicast_pkts(d),
        |s| s.netdev.and_then(|n| n.in_multicast_pkts).map(Value::Int),
    ),
    (
        |d| Subject::device_if_in_pkts(d),
        |s| s.netdev.and_then(|n| n.in_pkts).map(Value::Int),
    ),
    (
        |d| Subject::device_if_out_pkts(d),
        |s| s.netdev.and_then(|n| n.out_pkts).map(Value::Int),
    ),
    (
        |d| Subject::device_if_qdisc_backlog_bytes(d),
        |s| s.netdev.and_then(|n| n.qdisc_backlog_bytes).map(Value::Int),
    ),
    (
        |d| Subject::device_if_qdisc_backlog_pkts(d),
        |s| s.netdev.and_then(|n| n.qdisc_backlog_pkts).map(Value::Int),
    ),
];

/// Every counter this producer publishes, in the order it publishes them.
///
/// `pub` because the router ACLs have to be checked against it. The RF router
/// denies the management plane **by name** — deny is evaluated first and
/// returns immediately, so a carve-out has to be an absence — and
/// `tests/shipped_configs.rs` checks the rules against this list rather than
/// against a transcription of it.
pub fn subjects(device: &str) -> Vec<Subject> {
    READINGS.iter().map(|(name, _)| name(device)).collect()
}

/// The values, in [`subjects`]' order — both derived from `READINGS`, so the
/// order is one fact rather than two that have to agree.
/// The readings an SDU plane would publish this tick, in [`subjects`]'
/// order — `pub` so a driver's own tests can read them without a session.
pub fn values(plane: &dyn SduPlane) -> Vec<Option<Value>> {
    values_of(&Snapshot::of(plane))
}

/// The readings a netdev would publish this tick (#130), in [`subjects`]'
/// order: the kernel's counters under `if/`, and nothing an SDU plane
/// measures.
pub fn netdev_values(dev: &dyn modem_device::Netdev) -> Vec<Option<Value>> {
    values_of(&Snapshot::of_netdev(dev))
}

fn values_of(snap: &Snapshot) -> Vec<Option<Value>> {
    READINGS.iter().map(|(_, read)| read(snap)).collect()
}

pub async fn publish_loop(
    session: Session,
    origin: LocalOrigin,
    device: String,
    source: Source,
    interval: Duration,
) {
    // Declared once, not per sample: a declared publisher interns its key, so
    // every subsequent sample carries a varint id instead of the key bytes.
    // That is the difference between a readable keyspace being free and being
    // charged for on every publication.
    let mut publishers = Vec::new();
    for subject in subjects(&device) {
        // The profile comes off the subject, which reads it from the registry.
        // It was `QosProfile::Sampled` written here, which is the same value
        // and a second place to change it.
        let qos = subject.qos();
        let key = modem_contract::registry::modem::key(&origin, &subject);
        match session
            .declare_publisher(key.as_keyexpr().to_owned())
            .congestion_control(qos.congestion_control())
            .priority(qos.priority())
            .express(qos.express())
            // All four axes, not three. Omitting reliability leaves the zenoh
            // default (Reliable) while the profile says BestEffort, and the
            // mismatch is observable on the wire — `zenctl topic echo` reports
            // the QoS a sample actually carried, and `doctor --listen` fails on
            // declared-versus-observed. A convention nobody checks is prose.
            .reliability(qos.reliability())
            .await
        {
            Ok(p) => publishers.push(p),
            Err(e) => {
                tracing::error!(key = %key, error = %e, "could not declare a telemetry publisher");
                return;
            }
        }
    }

    loop {
        // Re-read every tick and zipped by position against the publishers,
        // which were declared from `subjects` in the same order. Both are a
        // single `vec![]` with no branches, so neither can reorder under the
        // other.
        for (publisher, value) in publishers.iter().zip(values_of(&source.snapshot())) {
            // Absent is not published (#115): the subject's ledger line says
            // it may be silent, and a consumer reads silence as "not measured"
            // rather than as a zero it would have to believe.
            let Some(value) = value else {
                continue;
            };
            if let Err(e) = publisher
                .put(value.to_string())
                .encoding(zenoh::bytes::Encoding::APPLICATION_JSON)
                .await
            {
                // Named, because "telemetry publication failed" without the
                // subject is a line an operator cannot act on.
                tracing::debug!(
                    key = %publisher.key_expr(),
                    error = %e,
                    "telemetry publication failed"
                );
            }
        }
        tokio::time::sleep(interval).await;
    }
}