refactor(proxy): reuse DB callback helper for config-file registration

The config-file loop reached into litellm._known_custom_logger_compatible_callbacks
(2 new private accesses) which trips the basedpyright per-rule budget.
Route it through the existing _add_callback_from_db_to_in_memory_litellm_callbacks
helper instead: same known-list check, same instance registration, plus the
string fallback now living in _add_custom_logger_callback_to_specific_event
for when the custom-logger class cannot initialize. Net private API surface
change vs base: zero.
This commit is contained in:
wadrzl55333 2026-08-28 21:34:08 +08:00
parent d02f573e52
commit d9da2db043
2 changed files with 11 additions and 22 deletions

View file

@ -702,7 +702,7 @@ from litellm.types.secret_managers.main import (
)
from litellm.types.utils import CredentialItem, CustomHuggingfaceTokenizer, RawRequestTypedDict, StandardLoggingPayload
from litellm.types.utils import ModelInfo as ModelMapInfo
from litellm.utils import _add_custom_logger_callback_to_specific_event, register_config_custom_logger_callback
from litellm.utils import _add_custom_logger_callback_to_specific_event
try:
from litellm._version import version
@ -5121,10 +5121,11 @@ class ProxyConfig:
)
# these are litellm callbacks - "langfuse", "sentry", "wandb"
else:
if callback in litellm._known_custom_logger_compatible_callbacks:
register_config_custom_logger_callback(callback, "success")
else:
litellm.logging_callback_manager.add_litellm_success_callback(callback)
self._add_callback_from_db_to_in_memory_litellm_callbacks(
callback=callback,
event_types=["success"],
existing_callbacks=litellm.success_callback,
)
if "prometheus" in callback:
from litellm.integrations.prometheus import (
PrometheusLogger,
@ -5151,10 +5152,11 @@ class ProxyConfig:
)
# these are litellm callbacks - "langfuse", "sentry", "wandb"
else:
if callback in litellm._known_custom_logger_compatible_callbacks:
register_config_custom_logger_callback(callback, "failure")
else:
litellm.logging_callback_manager.add_litellm_failure_callback(callback)
self._add_callback_from_db_to_in_memory_litellm_callbacks(
callback=callback,
event_types=["failure"],
existing_callbacks=litellm.failure_callback,
)
print( # noqa: T201
f"{blue_color_code} Initialized Failure Callbacks - {litellm.failure_callback} {reset_color_code}"
)

View file

@ -604,19 +604,6 @@ def _add_custom_logger_callback_to_specific_event(callback: str, logging_event:
litellm.logging_callback_manager.add_litellm_failure_callback(callback)
def register_config_custom_logger_callback(callback: str, logging_event: Literal["success", "failure"]) -> None:
"""Register a config-file custom-logger name as an instance, not a string.
Config-file ``success_callback`` / ``failure_callback`` strings previously
landed in ``litellm.success_callback`` as bare strings; pass-through
endpoints log through the async path only, so they never saw them.
Registering the custom-logger instance covers both paths. Falls back to
string registration when the class cannot be initialized (e.g. missing env
credentials), so standard-route logging keeps working.
"""
_add_custom_logger_callback_to_specific_event(callback, logging_event)
def _custom_logger_class_exists_in_success_callbacks(
callback_class: CustomLogger,
) -> bool: