fix(adminrpc): pass otel_enabled as defer arg to avoid double-init
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:
parent
acd7fe8f6c
commit
f125fb0c02
@ -15,7 +15,8 @@ use args::Args;
|
|||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
let cfg = AppConfig::load();
|
let cfg = AppConfig::load();
|
||||||
let log_level = cfg.log_level().unwrap_or_else(|_| "info".to_string());
|
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 args = Args::parse();
|
||||||
let grpc_addr: SocketAddr = args
|
let grpc_addr: SocketAddr = args
|
||||||
@ -34,7 +35,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
"Starting admin RPC server"
|
"Starting admin RPC server"
|
||||||
);
|
);
|
||||||
|
|
||||||
let _otel_guard = if cfg.otel_enabled().unwrap_or(false) {
|
let _otel_guard = if otel_enabled {
|
||||||
let endpoint = cfg
|
let endpoint = cfg
|
||||||
.otel_endpoint()
|
.otel_endpoint()
|
||||||
.unwrap_or_else(|_| "http://localhost:4317".to_string());
|
.unwrap_or_else(|_| "http://localhost:4317".to_string());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user