fix(adminrpc): pass otel_enabled as defer arg to avoid double-init
Some checks are pending
CI / Rust Lint & Check (push) Waiting to run
CI / Rust Tests (push) Waiting to run
CI / Frontend Lint & Type Check (push) Waiting to run
CI / Frontend Build (push) Blocked by required conditions

When OTLP is enabled, init_tracing_subscriber() must defer so that
init_otlp() is the sole caller of try_init(). Without this, the adminrpc
binary crashes with "global default trace dispatcher already set".
This commit is contained in:
ZhenYi 2026-04-22 23:47:15 +08:00
parent acd7fe8f6c
commit f125fb0c02

View File

@ -15,7 +15,8 @@ use args::Args;
async fn main() -> anyhow::Result<()> {
let cfg = AppConfig::load();
let log_level = cfg.log_level().unwrap_or_else(|_| "info".to_string());
observability::init_tracing_subscriber(&log_level, false);
let otel_enabled = cfg.otel_enabled().unwrap_or(false);
observability::init_tracing_subscriber(&log_level, otel_enabled);
let args = Args::parse();
let grpc_addr: SocketAddr = args
@ -34,7 +35,7 @@ async fn main() -> anyhow::Result<()> {
"Starting admin RPC server"
);
let _otel_guard = if cfg.otel_enabled().unwrap_or(false) {
let _otel_guard = if otel_enabled {
let endpoint = cfg
.otel_endpoint()
.unwrap_or_else(|_| "http://localhost:4317".to_string());