Add observability using the tracing crate

This commit is contained in:
2022-01-10 14:41:11 +01:00
parent a9942002b2
commit 747e962bc9
10 changed files with 364 additions and 192 deletions

View File

@@ -1,9 +1,18 @@
use contextswitch_api::observability::{get_subscriber, init_subscriber};
use contextswitch_api::taskwarrior;
use mktemp::Temp;
use once_cell::sync::Lazy;
use std::fs;
use std::net::TcpListener;
static TRACING: Lazy<()> = Lazy::new(|| {
let subscriber = get_subscriber("info".to_string());
init_subscriber(subscriber);
});
pub fn spawn_app() -> String {
Lazy::force(&TRACING);
let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind random port");
let port = listener.local_addr().unwrap().port();