summaryrefslogtreecommitdiff
path: root/src/reporting.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/reporting.rs')
-rw-r--r--src/reporting.rs39
1 files changed, 39 insertions, 0 deletions
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<Rate<i64>>,
+ pub request_out: Aspect<Rate<i64>>,
+ pub hosts: HashMap<String, HostReporting>,
+ // pub connections: Aspect<State<i64>>,
+}
+pub struct HostReporting {
+ pub requests_in: Aspect<Rate<i64>>,
+}
+
+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::<i64>))),
+ request_out: rep.create(make_ident!("requests-out"), Push(Rate(PhantomData::<i64>))),
+ // 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::<i64>)),
+ ),
+ },
+ )
+ })
+ .collect(),
+ }
+ }
+}