mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
(fix) initializing OTEL Logging on LiteLLM Proxy - ensure OTEL logger is initialized only once (#7435)
* add otel to _custom_logger_compatible_callbacks_literal * remove extra code * fix _get_custom_logger_settings_from_proxy_server * update unit tests
This commit is contained in:
parent
539f166166
commit
17d5ff2fa4
6 changed files with 45 additions and 45 deletions
|
@ -17,7 +17,7 @@ def initialize_callbacks_on_proxy( # noqa: PLR0915
|
|||
litellm_settings: dict,
|
||||
callback_specific_params: dict = {},
|
||||
):
|
||||
from litellm.proxy.proxy_server import callback_settings, prisma_client
|
||||
from litellm.proxy.proxy_server import prisma_client
|
||||
|
||||
verbose_proxy_logger.debug(
|
||||
f"{blue_color_code}initializing callbacks={value} on proxy{reset_color_code}"
|
||||
|
@ -30,22 +30,6 @@ def initialize_callbacks_on_proxy( # noqa: PLR0915
|
|||
and callback in litellm._known_custom_logger_compatible_callbacks
|
||||
):
|
||||
imported_list.append(callback)
|
||||
elif isinstance(callback, str) and callback == "otel":
|
||||
from litellm.integrations.opentelemetry import OpenTelemetry
|
||||
from litellm.proxy import proxy_server
|
||||
|
||||
_otel_settings = {}
|
||||
if isinstance(callback_settings, dict) and "otel" in callback_settings:
|
||||
_otel_settings = callback_settings["otel"]
|
||||
|
||||
open_telemetry_logger = OpenTelemetry(**_otel_settings)
|
||||
|
||||
# Add Otel as a service callback
|
||||
if "otel" not in litellm.service_callback:
|
||||
litellm.service_callback.append("otel")
|
||||
|
||||
imported_list.append(open_telemetry_logger)
|
||||
setattr(proxy_server, "open_telemetry_logger", open_telemetry_logger)
|
||||
elif isinstance(callback, str) and callback == "presidio":
|
||||
from litellm.proxy.guardrails.guardrail_hooks.presidio import (
|
||||
_OPTIONAL_PresidioPIIMasking,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue