mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-07 00:00:12 +02:00
Refactor initializing tracing-subscriber
This commit is contained in:
@@ -21,7 +21,6 @@ use std::{
|
||||
net::SocketAddr,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
fn metrics_app() -> Router {
|
||||
let recorder_handle = setup_metrics_recorder();
|
||||
@@ -65,12 +64,11 @@ async fn start_metrics_server() {
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::registry()
|
||||
.with(tracing_subscriber::EnvFilter::new(
|
||||
std::env::var("RUST_LOG")
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| "example_todos=debug,tower_http=debug".into()),
|
||||
))
|
||||
.with(tracing_subscriber::fmt::layer())
|
||||
)
|
||||
.init();
|
||||
|
||||
// The `/metrics` endpoint should not be publicly available. If behind a reverse proxy, this
|
||||
|
||||
Reference in New Issue
Block a user