Add tracing.

This commit is contained in:
Tom Alexander
2024-07-14 15:34:14 -04:00
parent 82a5f145e1
commit 25c06cbffd
3 changed files with 196 additions and 1 deletions

View File

@@ -3,13 +3,23 @@ use axum::routing::get;
use axum::Json;
use axum::Router;
use serde::Serialize;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
"webhook_bridge=info,tower_http=debug,axum::rejection=trace".into()
}),
)
.with(tracing_subscriber::fmt::layer())
.init();
let app = Router::new().route("/health", get(health));
let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await?;
println!("Listening on port 8080. Pop open your browser to http://127.0.0.1:8080/ .");
tracing::info!("listening on {}", listener.local_addr().unwrap());
axum::serve(listener, app).await?;
Ok(())
}