Unverified Commit af26a013 authored by Anthony Casagrande's avatar Anthony Casagrande Committed by GitHub
Browse files

fix: kvbm defer logging init to after tokio runtime is available (#4123)


Signed-off-by: default avatarAnthony Casagrande <acasagrande@nvidia.com>
parent 02763376
...@@ -20,9 +20,22 @@ mod block_manager; ...@@ -20,9 +20,22 @@ mod block_manager;
/// import the module. /// import the module.
#[pymodule] #[pymodule]
fn _core(m: &Bound<'_, PyModule>) -> PyResult<()> { fn _core(m: &Bound<'_, PyModule>) -> PyResult<()> {
logging::init(); // Initialize tokio runtime first to avoid panics when OTEL_EXPORT_ENABLED=1
init_pyo3_tokio_rt(); init_pyo3_tokio_rt();
if std::env::var("OTEL_EXPORT_ENABLED")
.map(|v| v == "1")
.unwrap_or(false)
{
// OTLP batch exporter needs runtime context to spawn background tasks
let handle = get_current_tokio_handle();
let _guard = handle.enter();
logging::init();
} else {
// OTEL disabled: no runtime context needed
logging::init();
}
#[cfg(feature = "block-manager")] #[cfg(feature = "block-manager")]
block_manager::add_to_module(m)?; block_manager::add_to_module(m)?;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment