channels-console 0.3.3

Real-time monitoring, metrics and logs for Rust channels.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use channels_console::{ChannelLogs, MetricsJson};
use eyre::Result;

/// Fetches channel metrics from the HTTP server
pub(crate) fn fetch_metrics(agent: &ureq::Agent, port: u16) -> Result<MetricsJson> {
    let url = format!("http://127.0.0.1:{}/metrics", port);
    let metrics: MetricsJson = agent.get(&url).call()?.body_mut().read_json()?;
    Ok(metrics)
}

/// Fetches logs for a specific channel from the HTTP server
pub(crate) fn fetch_logs(agent: &ureq::Agent, port: u16, channel_id: u64) -> Result<ChannelLogs> {
    let url = format!("http://127.0.0.1:{}/logs/{}", port, channel_id);
    let logs: ChannelLogs = agent.get(&url).call()?.body_mut().read_json()?;
    Ok(logs)
}