From 6e4095bd811a53cb75092516ef303b746e9aafba Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 6 Oct 2023 10:22:31 +0200 Subject: some basic reporting for mond --- src/reporting.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/reporting.rs (limited to 'src/reporting.rs') diff --git a/src/reporting.rs b/src/reporting.rs new file mode 100644 index 0000000..ee30ac5 --- /dev/null +++ b/src/reporting.rs @@ -0,0 +1,39 @@ +use crate::config::Config; +use mond_client::{make_ident, Aspect, Push, Rate, Reporter}; +use std::{collections::HashMap, marker::PhantomData}; + +pub struct Reporting { + pub request_in: Aspect>, + pub request_out: Aspect>, + pub hosts: HashMap, + // pub connections: Aspect>, +} +pub struct HostReporting { + pub requests_in: Aspect>, +} + +impl Reporting { + pub fn new(config: &Config) -> Self { + let mut rep = Reporter::new(); + Self { + request_in: rep.create(make_ident!("requests-in"), Push(Rate(PhantomData::))), + request_out: rep.create(make_ident!("requests-out"), Push(Rate(PhantomData::))), + // connections: rep.create(make_ident!("connections"), Push()), + hosts: config + .hosts + .iter() + .map(|(k, _v)| { + ( + k.to_owned(), + HostReporting { + requests_in: rep.create( + make_ident!("host", k, "request-in"), + Push(Rate(PhantomData::)), + ), + }, + ) + }) + .collect(), + } + } +} -- cgit v1.2.3-70-g09d2