Skip to content

Commit 791549a

Browse files
committed
make console subscriber opt in with --console flag
1 parent a77582b commit 791549a

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ humantime-serde = "1.1"
1818
hyper = { version = "1.2.0", features = ["full"] }
1919
hyper-util = { version = "0.1.3", features = ["full"] }
2020
http-body-util = "0.1.0"
21-
jemallocator = "0.5.4"
21+
jemallocator = { version = "0.5.4" }
2222
once_cell = "1.17.1"
2323
ott-common = { path = "crates/ott-common" }
2424
ott-balancer = { path = "crates/ott-balancer" }

crates/ott-balancer/src/config.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,14 @@ pub struct Cli {
7979
#[clap(short, long, default_value_t = LogLevel::Info, value_enum)]
8080
pub log_level: LogLevel,
8181

82+
/// Enable the console-subscriber for debugging via tokio-console.
83+
#[clap(long)]
84+
pub console: bool,
85+
8286
/// Allow remote connections via tokio-console for debugging. By default, only local connections are allowed.
8387
///
8488
/// The default port for tokio-console is 6669.
85-
#[clap(long)]
89+
#[clap(long, requires("console"))]
8690
pub remote_console: bool,
8791

8892
/// Validate the configuration file.

crates/ott-balancer/src/lib.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,22 @@ pub async fn run() -> anyhow::Result<()> {
5656

5757
let config = BalancerConfig::get();
5858

59-
let console_layer = if args.remote_console {
60-
console_subscriber::ConsoleLayer::builder()
61-
.server_addr((
62-
Ipv6Addr::UNSPECIFIED,
63-
console_subscriber::Server::DEFAULT_PORT,
64-
))
65-
.spawn()
59+
let console_layer = if args.console {
60+
let console_layer = if args.remote_console {
61+
console_subscriber::ConsoleLayer::builder()
62+
.server_addr((
63+
Ipv6Addr::UNSPECIFIED,
64+
console_subscriber::Server::DEFAULT_PORT,
65+
))
66+
.spawn()
67+
} else {
68+
console_subscriber::ConsoleLayer::builder().spawn()
69+
}
70+
.with_filter(EnvFilter::try_new("tokio=trace,runtime=trace")?);
71+
Some(console_layer)
6672
} else {
67-
console_subscriber::ConsoleLayer::builder().spawn()
73+
None
6874
};
69-
let console_layer = console_layer.with_filter(EnvFilter::try_new("tokio=trace,runtime=trace")?);
7075
let filter = args.build_tracing_filter();
7176
let filter_layer = EnvFilter::try_from_default_env().or_else(|_| EnvFilter::try_new(filter))?;
7277
let fmt_layer = tracing_subscriber::fmt::layer().with_filter(filter_layer);

0 commit comments

Comments
 (0)