Skip to main content

naia_metrics/
lib.rs

1//! Observability emission layer for naia game networking.
2//!
3//! Emits network health data — RTT, jitter, packet loss, bandwidth — via the
4//! [`metrics`] crate facade. Install any compatible exporter at startup and
5//! naia's data flows to your monitoring backend automatically.
6//!
7//! # Non-Bevy usage
8//!
9//! Call once per tick after `server.send_all_packets()`:
10//!
11//! ```rust,ignore
12//! naia_metrics::emit_server_aggregates(
13//!     server.user_count(),
14//!     server.entity_count(),
15//!     server.room_count(),
16//! );
17//! for user_key in server.user_keys() {
18//!     if let Some(stats) = server.connection_stats(&user_key) {
19//!         naia_metrics::emit_server_connection_stats(&stats, user_key.to_u64());
20//!     }
21//! }
22//! ```
23//!
24//! For Bevy apps, use [`naia-bevy-metrics`] instead — it handles emission
25//! automatically via a plugin.
26
27pub mod names;
28mod server;
29mod client;
30
31pub use server::{emit_server_aggregates, emit_server_connection_stats};
32pub use client::emit_client_connection_stats;