diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 27132c90e05..5ca5fea9c60 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -5318,6 +5318,7 @@ class ProxyConfig: # these are litellm callbacks - "langfuse", "sentry", "wandb" else: litellm.logging_callback_manager.add_litellm_success_callback(callback) + _add_custom_logger_callback_to_specific_event(callback, "success") if "prometheus" in callback: from litellm.integrations.prometheus import ( PrometheusLogger, @@ -5345,6 +5346,7 @@ class ProxyConfig: # these are litellm callbacks - "langfuse", "sentry", "wandb" else: litellm.logging_callback_manager.add_litellm_failure_callback(callback) + _add_custom_logger_callback_to_specific_event(callback, "failure") print( # noqa: T201 f"{blue_color_code} Initialized Failure Callbacks - {litellm.failure_callback} {reset_color_code}" ) diff --git a/tests/test_litellm/proxy/test_proxy_server.py b/tests/test_litellm/proxy/test_proxy_server.py index 4ed6a468371..a2c4ae9878a 100644 --- a/tests/test_litellm/proxy/test_proxy_server.py +++ b/tests/test_litellm/proxy/test_proxy_server.py @@ -3153,6 +3153,29 @@ async def test_custom_ui_sso_sign_in_handler_config_loading(): os.unlink(config_file_path) +@pytest.mark.asyncio +async def test_load_config_eagerly_initializes_string_success_callback(tmp_path, monkeypatch): + from litellm.integrations.generic_api.generic_api_callback import GenericAPILogger + from litellm.proxy.proxy_server import ProxyConfig + + config_file = tmp_path / "config.yaml" + config_file.write_text( + "model_list: []\n" + "litellm_settings:\n" + " success_callback:\n" + " - generic_api\n" + ) + monkeypatch.setenv("GENERIC_LOGGER_ENDPOINT", "http://127.0.0.1:8899/") + + monkeypatch.setattr(litellm, "success_callback", []) + monkeypatch.setattr(litellm, "_async_success_callback", []) + monkeypatch.setattr(litellm, "failure_callback", []) + monkeypatch.setattr(litellm, "_async_failure_callback", []) + await ProxyConfig().load_config(router=MagicMock(), config_file_path=str(config_file)) + assert any(isinstance(callback, GenericAPILogger) for callback in litellm._async_success_callback) + assert "generic_api" not in litellm.success_callback + + @pytest.mark.asyncio async def test_load_config_max_budget_env_var_coerced_to_float(tmp_path, monkeypatch): """