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