pub mod aggregator;
pub mod collector;
pub mod config;
pub mod validator;
pub mod metrics {
use std::sync::atomic::{AtomicU64, Ordering};
pub static EVENTS_RECEIVED: AtomicU64 = AtomicU64::new(0);
pub static MODEL_UPLOADS: AtomicU64 = AtomicU64::new(0);
pub static INFERENCE_REQUESTS: AtomicU64 = AtomicU64::new(0);
pub static WRITES_FLUSHED: AtomicU64 = AtomicU64::new(0);
pub fn inc_events() {
EVENTS_RECEIVED.fetch_add(1, Ordering::SeqCst);
}
pub fn inc_models() {
MODEL_UPLOADS.fetch_add(1, Ordering::SeqCst);
}
pub fn inc_inference() {
INFERENCE_REQUESTS.fetch_add(1, Ordering::SeqCst);
}
pub fn inc_writes_flushed() {
WRITES_FLUSHED.fetch_add(1, Ordering::SeqCst);
}
pub fn snapshot() -> (u64, u64, u64, u64) {
(
EVENTS_RECEIVED.load(Ordering::SeqCst),
MODEL_UPLOADS.load(Ordering::SeqCst),
INFERENCE_REQUESTS.load(Ordering::SeqCst),
WRITES_FLUSHED.load(Ordering::SeqCst),
)
}
pub fn to_prometheus_text() -> String {
let (ev, mo, inf, wf) = snapshot();
let mut out = String::new();
out.push_str("# TYPE json_engine_events_received counter\n");
out.push_str(&format!("json_engine_events_received {}\n", ev));
out.push_str("# TYPE json_engine_model_uploads counter\n");
out.push_str(&format!("json_engine_model_uploads {}\n", mo));
out.push_str("# TYPE json_engine_inference_requests counter\n");
out.push_str(&format!("json_engine_inference_requests {}\n", inf));
out.push_str("# TYPE json_engine_writes_flushed counter\n");
out.push_str(&format!("json_engine_writes_flushed {}\n", wf));
out
}
}
pub use crate::collector::model_store;
pub use crate::collector::vocab;
pub use crate::config::atomic;
pub use crate::config::json;
pub use crate::aggregator::*;
pub use crate::collector::*;
pub use crate::config::*;
pub use crate::validator::*;