fraiseql-wire 2.3.0

Streaming JSON query engine for Postgres 17
Documentation
//! Gauge metrics for fraiseql-wire
//!
//! Gauges track instantaneous values that can increase or decrease:
//! - Current chunk size in bytes
//! - Stream buffered items count
//! - Real-time monitoring of stream health

use crate::metrics::labels;
use metrics::gauge;

/// Record current chunk size
///
/// Called after chunk size adjustments to reflect the current size
/// used for buffering rows from Postgres.
pub fn current_chunk_size(entity: &str, bytes: usize) {
    gauge!(
        "fraiseql_chunk_size_bytes",
        labels::ENTITY => entity.to_string(),
    )
    .set(bytes as f64);
}

/// Record stream buffered items count
///
/// Tracks how many rows are currently buffered in the async channel.
/// High values indicate consumer is slow relative to producer.
pub fn stream_buffered_items(entity: &str, count: usize) {
    gauge!(
        "fraiseql_stream_buffered_items",
        labels::ENTITY => entity.to_string(),
    )
    .set(count as f64);
}

#[cfg(test)]
mod tests;