Unverified Commit d22d9e76 authored by Neelay Shah's avatar Neelay Shah Committed by GitHub
Browse files

fix: support truthy values for OTEL_EXPORT_ENABLED in bindings layer [DYN-1690][DYN-1646] (#5129)


Co-authored-by: default avatarClaude <noreply@anthropic.com>
parent cf433e68
......@@ -9,7 +9,7 @@ use std::{fmt::Display, sync::Arc};
use tokio::sync::Mutex;
use tokio_util::sync::CancellationToken;
use dynamo_runtime::{self as rs, RuntimeConfig, logging, traits::DistributedRuntimeProvider};
use dynamo_runtime::{self as rs, RuntimeConfig, logging, traits::DistributedRuntimeProvider, config};
use dynamo_llm::{self as llm_rs};
......@@ -23,9 +23,7 @@ fn _core(m: &Bound<'_, PyModule>) -> PyResult<()> {
// Initialize tokio runtime first to avoid panics when OTEL_EXPORT_ENABLED=1
init_pyo3_tokio_rt();
if std::env::var("OTEL_EXPORT_ENABLED")
.map(|v| v == "1")
.unwrap_or(false)
if config::env_is_truthy("OTEL_EXPORT_ENABLED")
{
// OTLP batch exporter needs runtime context to spawn background tasks
let handle = get_current_tokio_handle();
......
......@@ -22,6 +22,7 @@ use std::{
use tokio::sync::Mutex;
use tracing::Instrument;
use dynamo_runtime::config;
use dynamo_runtime::config::environment_names::logging::otlp as env_otlp;
use dynamo_runtime::{
self as rs, logging,
......@@ -126,10 +127,7 @@ fn create_request_context(
#[pymodule]
fn _core(m: &Bound<'_, PyModule>) -> PyResult<()> {
// Initialize logging early unless OTEL export is enabled (which requires tokio runtime)
if std::env::var(env_otlp::OTEL_EXPORT_ENABLED)
.map(|v| v == "1")
.unwrap_or(false)
{
if config::env_is_truthy(env_otlp::OTEL_EXPORT_ENABLED) {
eprintln!(
"Warning: OTEL_EXPORT_ENABLED detected. Logging initialization deferred until runtime is available. Early logs may be dropped."
);
......@@ -562,10 +560,7 @@ impl DistributedRuntime {
// Initialize logging in context where tokio runtime is available
// otel exporter requires it
if std::env::var(env_otlp::OTEL_EXPORT_ENABLED)
.map(|v| v == "1")
.unwrap_or(false)
{
if config::env_is_truthy(env_otlp::OTEL_EXPORT_ENABLED) {
runtime.secondary().block_on(async {
rs::logging::init();
});
......
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