diff --git a/litellm/integrations/traceloop.py b/litellm/integrations/traceloop.py index be53de0e90..33b9c92da9 100644 --- a/litellm/integrations/traceloop.py +++ b/litellm/integrations/traceloop.py @@ -1,7 +1,8 @@ class TraceloopLogger: def __init__(self): from traceloop.sdk.tracing.tracing import TracerWrapper - + from traceloop.sdk import Traceloop + Traceloop.init(app_name="Litellm-Server", disable_batch=True) self.tracer_wrapper = TracerWrapper() def log_event(self, kwargs, response_obj, start_time, end_time, print_verbose): diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index d92280df3a..e942d4d418 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -319,7 +319,6 @@ async def user_api_key_auth(request: Request, api_key: str = fastapi.Security(ap def prisma_setup(database_url: Optional[str]): global prisma_client, proxy_logging_obj, user_api_key_cache - proxy_logging_obj._init_litellm_callbacks() if database_url is not None: try: prisma_client = PrismaClient(database_url=database_url, proxy_logging_obj=proxy_logging_obj) @@ -527,10 +526,6 @@ def load_router_config(router: Optional[litellm.Router], config_file_path: str): # these are litellm callbacks - "langfuse", "sentry", "wandb" else: litellm.success_callback.append(callback) - if callback == "traceloop": - from traceloop.sdk import Traceloop - print_verbose(f"{blue_color_code} Initializing Traceloop SDK - \nRunning:`Traceloop.init(app_name='Litellm-Server', disable_batch=True)`") - Traceloop.init(app_name="Litellm-Server", disable_batch=True) print_verbose(f"{blue_color_code} Initialized Success Callbacks - {litellm.success_callback} {reset_color_code}") elif key == "failure_callback": litellm.failure_callback = [] @@ -816,11 +811,9 @@ def get_litellm_model_info(model: dict = {}): @router.on_event("startup") async def startup_event(): - global prisma_client, master_key, use_background_health_checks, use_queue + global prisma_client, master_key, use_background_health_checks import json - print(f"VALUE OF USE_QUEUE: {use_queue}") - ### LOAD CONFIG ### worker_config = litellm.get_secret("WORKER_CONFIG") print_verbose(f"worker_config: {worker_config}") @@ -833,6 +826,8 @@ async def startup_event(): initialize(**worker_config) + proxy_logging_obj._init_litellm_callbacks() # INITIALIZE LITELLM CALLBACKS ON SERVER STARTUP <- do this to catch any logging errors on startup, not when calls are being made + if use_background_health_checks: asyncio.create_task(_run_background_health_check()) # start the background health check coroutine. diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index e7f37e2058..938508bcc7 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -7,7 +7,7 @@ from litellm.proxy.hooks.parallel_request_limiter import MaxParallelRequestsHand from litellm.integrations.custom_logger import CustomLogger def print_verbose(print_statement): if litellm.set_verbose: - print(print_statement) # noqa + print(f"LiteLLM Proxy: {print_statement}") # noqa ### LOGGING ### class ProxyLogging: """ @@ -26,7 +26,7 @@ class ProxyLogging: pass def _init_litellm_callbacks(self): - + print_verbose(f"INITIALIZING LITELLM CALLBACKS!") litellm.callbacks.append(self.max_parallel_request_limiter) for callback in litellm.callbacks: if callback not in litellm.input_callback: diff --git a/litellm/router.py b/litellm/router.py index 96d90dde08..1b8dc1172e 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -386,7 +386,7 @@ class Router: self.print_verbose(f'Async Response: {response}') return response except Exception as e: - self.print_verbose(f"An exception occurs: {e}") + self.print_verbose(f"An exception occurs: {e}\n\n Traceback{traceback.format_exc()}") original_exception = e try: self.print_verbose(f"Trying to fallback b/w models") diff --git a/requirements.txt b/requirements.txt index cd7780fb89..bc849a325d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,4 +18,5 @@ celery psutil mangum google-generativeai -async_generator # for ollama +traceloop-sdk==0.5.3 +langfuse==1.14.0