From 8761c88fe126ec5714c8db343234b651670059dd Mon Sep 17 00:00:00 2001 From: yucheng Date: Sat, 26 Sep 2026 15:55:40 +0000 Subject: [PATCH] fix(otel): hoist the preset check out of the callback loop Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/proxy/common_utils/callback_utils.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/litellm/proxy/common_utils/callback_utils.py b/litellm/proxy/common_utils/callback_utils.py index 50b0b0faa64..837361e7232 100644 --- a/litellm/proxy/common_utils/callback_utils.py +++ b/litellm/proxy/common_utils/callback_utils.py @@ -148,6 +148,11 @@ def initialize_callbacks_on_proxy( verbose_proxy_logger.debug("%sinitializing callbacks=%s on proxy%s", blue_color_code, value, reset_color_code) if isinstance(value, list): + from litellm.integrations.otel.presets import PRESET_BY_CALLBACK + + preset_present: Final = any( + isinstance(entry, str) and entry != "otel" and entry in PRESET_BY_CALLBACK for entry in value + ) imported_list: Final[list[Any]] = [] for callback in value: # ["presidio", ] if isinstance(callback, str) and callback == "compression_interception": @@ -180,11 +185,7 @@ def initialize_callbacks_on_proxy( validate_otel_v2_callback_settings(callback_specific_params.get("otel")) from litellm.integrations.otel.model.config import validate_otel_v2_excluded_services_env - from litellm.integrations.otel.presets import PRESET_BY_CALLBACK - preset_present: Final = any( - isinstance(entry, str) and entry != "otel" and entry in PRESET_BY_CALLBACK for entry in value - ) validate_otel_v2_excluded_services_env( callback_specific_params.get("otel") if "otel" in value and not preset_present else None )