Add metrics to web endpoint

This commit is contained in:
Alex Auvolat
2022-02-22 15:21:06 +01:00
parent 2a5609b292
commit d9a35359bf
7 changed files with 168 additions and 84 deletions
+8 -1
View File
@@ -1,8 +1,9 @@
use std::time::SystemTime;
use futures::{future::BoxFuture, Future, FutureExt};
use rand::Rng;
use opentelemetry::{metrics::*, KeyValue};
use opentelemetry::{metrics::*, trace::TraceId, KeyValue};
pub trait RecordDuration<'a>: 'a {
type Output;
@@ -48,3 +49,9 @@ where
.boxed()
}
}
// ----
pub fn gen_trace_id() -> TraceId {
rand::thread_rng().gen::<[u8; 16]>().into()
}