Crate mecha10_diagnostics

Crate mecha10_diagnostics 

Source
Expand description

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

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

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(())
}

Modules§

collectors
Diagnostic collectors
metrics
Metric helper types for tracking and aggregating diagnostics
prelude
Convenient re-exports for common diagnostics types
topics
Diagnostic topic definitions
types
Diagnostic message types