about summary refs log tree commit diff
path: root/src/metrics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/metrics.rs')
-rw-r--r--src/metrics.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/metrics.rs b/src/metrics.rs
index 9f512dd..7bfa2d2 100644
--- a/src/metrics.rs
+++ b/src/metrics.rs
@@ -1,3 +1,4 @@
+#![allow(unused_imports, dead_code)]
 use async_trait::async_trait;
 use lazy_static::lazy_static;
 use prometheus::{
@@ -5,7 +6,7 @@ use prometheus::{
     TextEncoder,
 };
 use std::time::{Duration, Instant};
-use tide::{Next, Request, Response, Result};
+//use tide::{Next, Request, Response, Result};
 
 // Copied from https://docs.rs/prometheus/0.12.0/src/prometheus/histogram.rs.html#885-889
 #[inline]
@@ -29,7 +30,7 @@ lazy_static! {
     .unwrap();
 }
 
-pub struct InstrumentationMiddleware {}
+/*pub struct InstrumentationMiddleware {}
 
 #[async_trait]
 impl<S> tide::Middleware<S> for InstrumentationMiddleware
@@ -55,9 +56,9 @@ where
 
         Ok(res)
     }
-}
+}*/
 
-pub async fn gather<S>(_: Request<S>) -> Result
+/*pub async fn gather<S>(_: Request<S>) -> Result
 where
     S: Send + Sync + Clone,
 {
@@ -67,4 +68,18 @@ where
     encoder.encode(&metric_families, &mut buffer).unwrap();
 
     Ok(Response::builder(200).body(buffer).build())
+}*/
+
+// TODO metrics middleware
+// warp doesn't allow running a filter manually
+// so you need to escape into the world of hyper
+// to collect metrics on requests
+
+pub fn gather() -> Vec<u8> {
+    let mut buffer: Vec<u8> = vec![];
+    let encoder = TextEncoder::new();
+    let metric_families = prometheus::gather();
+    encoder.encode(&metric_families, &mut buffer).unwrap();
+
+    buffer
 }