/// Spawn a background task which dump the metrics to the log.  This task
/// does not terminate and if/when we support clean shutdown this task will
/// need to be joined.
Spawn a background task which dump the metrics to the log.  This task
does not terminate and if/when we support clean shutdown this task will
need to be joined.
Spawn a background task which dump the metrics to the log . This task does not terminate and if / when we support clean shutdown this task will need to be joined .
fn start_log(&self) {
        let log = self.log.clone();
        let metrics_registry = self.metrics_registry.clone();
        self.rt_handle.spawn(async move {
            let encoder = TextEncoder::new();
            let mut interval = tokio::time::interval(Duration::from_secs(LOG_INTERVAL_SECS));
            loop {
                interval.tick().await;
                let mut buffer = vec![];
                let metric_families = metrics_registry.prometheus_registry().gather();
                encoder.encode(&metric_families, &mut buffer).unwrap();
                let metrics = String::from_utf8(buffer).unwrap();
                trace!(log, "{}", metrics);
            }
        });
    }
fn start_log ( & self ) { let log = self . log . clone ( ) ; let metrics_registry = self . metrics_registry . clone ( ) ; self . rt_handle . spawn ( async move { let encoder = TextEncoder :: new ( ) ; let mut interval = tokio :: time :: interval ( Duration :: from_secs ( LOG_INTERVAL_SECS ) ) ; loop { interval . tick ( ) . await ; let mut buffer = vec ! [ ] ; let metric_families = metrics_registry . prometheus_registry ( ) . gather ( ) ; encoder . encode ( & metric_families , & mut buffer ) . unwrap ( ) ; let metrics = String :: from_utf8 ( buffer ) . unwrap ( ) ; trace ! ( log " " metrics ) ; } } ) ; }
Spawn a background task which dump the metrics to the log.
Spawn a background task which dump the metrics to the log .
&self