athena_rs 3.26.4

Hyper performant polyglot Database driver
Documentation
//! Health-reason entry builders for `/debug/schema`.
//!
//! This module owns shaping `LoggingSchemaDebugHealthReason` rows from static
//! reason specs and resolved aggregate counts.

use super::debug_health_reasons_specs::LoggingSchemaDebugHealthReasonSpec;
use super::debug_summary_contracts::LoggingSchemaDebugHealthReason;

/// Returns one fallback info reason for fully healthy summary metrics.
pub(super) fn build_all_expected_resources_present_reason() -> LoggingSchemaDebugHealthReason {
    LoggingSchemaDebugHealthReason {
        code: "all_expected_resources_present".to_string(),
        severity: "info".to_string(),
        count: 0,
        message: "All expected logging tables and columns are present".to_string(),
    }
}

/// Appends one structured reason row when the metric count is nonzero.
pub(super) fn push_reason_if_nonzero(
    reasons: &mut Vec<LoggingSchemaDebugHealthReason>,
    spec: LoggingSchemaDebugHealthReasonSpec,
    count: usize,
) {
    if count == 0 {
        return;
    }

    reasons.push(LoggingSchemaDebugHealthReason {
        code: spec.code.to_string(),
        severity: spec.severity.to_string(),
        count,
        message: spec.message.to_string(),
    });
}