From d9a35359bf8903f37f5f7aa77421ed35b626e0af Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 22 Feb 2022 15:21:06 +0100 Subject: Add metrics to web endpoint --- src/util/metrics.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/util') diff --git a/src/util/metrics.rs b/src/util/metrics.rs index cd5aa182..1b05eabe 100644 --- a/src/util/metrics.rs +++ b/src/util/metrics.rs @@ -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() +} -- cgit v1.2.3