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
//! Diagnostics Service
//!
//! Topic-based diagnostics and performance monitoring for Mecha10.
//!
//! # Architecture
//!
//! All diagnostics are published to topic hierarchy under `/diagnostics`:
//! - `/diagnostics/streaming/*` - Camera streaming pipeline metrics
//! - `/diagnostics/webrtc/*` - WebRTC connection and quality metrics
//! - `/diagnostics/websocket/*` - WebSocket connection metrics
//! - `/diagnostics/redis/*` - Redis connection pool and operation metrics
//! - `/diagnostics/docker/*` - Docker container resource metrics
//! - `/diagnostics/system/*` - System-level resource metrics
//! - `/diagnostics/node/{id}/health` - Per-node health metrics
//!
//! # Usage
//!
//! ## Publishing Diagnostics
//!
//! ```rust,no_run
//! use mecha10_diagnostics::prelude::*;
//! use mecha10_core::prelude::*;
//!
//! async fn publish_metrics(ctx: &Context) -> Result<()> {
//! // Publish streaming metrics
//! let metrics = StreamingPipelineMetrics {
//! timestamp: now_micros(),
//! frames_received: 1234,
//! frames_encoded: 1230,
//! frames_sent: 1228,
//! frames_dropped: 4,
//! bytes_per_second: 400_000,
//! };
//!
//! ctx.publish_to(
//! Topic::<DiagnosticMessage<StreamingPipelineMetrics>>::new(TOPIC_DIAGNOSTICS_STREAMING_PIPELINE),
//! &DiagnosticMessage::new("simulation-bridge", metrics)
//! ).await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Subscribing to Diagnostics
//!
//! ```rust,no_run
//! use mecha10_diagnostics::prelude::*;
//! use mecha10_core::prelude::*;
//!
//! async fn monitor_streaming(ctx: &Context) -> Result<()> {
//! let mut rx = ctx.subscribe(
//! Topic::<DiagnosticMessage<StreamingPipelineMetrics>>::new(TOPIC_DIAGNOSTICS_STREAMING_PIPELINE)
//! ).await?;
//!
//! while let Some(msg) = rx.recv().await {
//! println!("FPS: {}", msg.payload.frames_received);
//! }
//!
//! Ok(())
//! }
//! ```