From b64e4c3e6ff8f1d6e26896bb6367097ac9215378 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Thu, 7 Mar 2024 13:42:54 -0800 Subject: [PATCH 1/3] (feat) better debugging when reading prisma --- litellm/proxy/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 81130787d07..26ed35604bb 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -693,6 +693,9 @@ class PrismaClient: """ Generic implementation of get data """ + verbose_proxy_logger.debug( + f"PrismaClient: get_generic_data: {key}, table_name: {table_name}" + ) try: if table_name == "users": response = await self.db.litellm_usertable.find_first( @@ -758,6 +761,9 @@ class PrismaClient: int ] = None, # pagination, number of rows to getch when find_all==True ): + verbose_proxy_logger.debug( + f"PrismaClient: get_data: table_name: {table_name}, query_type: {query_type}, user_id: {user_id}, user_id_list: {user_id_list}, team_id: {team_id}, team_id_list: {team_id_list}, key_val: {key_val}" + ) try: response: Any = None if (token is not None and table_name is None) or ( @@ -1020,6 +1026,7 @@ class PrismaClient: Add a key to the database. If it already exists, do nothing. """ try: + verbose_proxy_logger.debug(f"PrismaClient: insert_data: {data}") if table_name == "key": token = data["token"] hashed_token = self.hash_token(token=token) @@ -1152,6 +1159,9 @@ class PrismaClient: """ Update existing data """ + verbose_proxy_logger.debug( + f"PrismaClient: update_data, table_name: {table_name}" + ) try: db_data = self.jsonify_object(data=data) if update_key_values is not None: From 5217e800c4ba6c5d4884983dd1e12c277e98673f Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Thu, 7 Mar 2024 14:04:02 -0800 Subject: [PATCH 2/3] (fix) better prisma debug logs --- litellm/proxy/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 26ed35604bb..0f0097ff6de 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -762,7 +762,7 @@ class PrismaClient: ] = None, # pagination, number of rows to getch when find_all==True ): verbose_proxy_logger.debug( - f"PrismaClient: get_data: table_name: {table_name}, query_type: {query_type}, user_id: {user_id}, user_id_list: {user_id_list}, team_id: {team_id}, team_id_list: {team_id_list}, key_val: {key_val}" + f"PrismaClient: get_data: token={token}, table_name: {table_name}, query_type: {query_type}, user_id: {user_id}, user_id_list: {user_id_list}, team_id: {team_id}, team_id_list: {team_id_list}, key_val: {key_val}" ) try: response: Any = None From 8c3ec15856d87d3689bd87f86bc485f711ade8a0 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Thu, 7 Mar 2024 15:44:03 -0800 Subject: [PATCH 3/3] (fix) improve improve prisma alerting/debug --- litellm/proxy/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 0f0097ff6de..32f7993607c 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -997,9 +997,11 @@ class PrismaClient: except Exception as e: import traceback - error_msg = f"LiteLLM Prisma Client Exception get_data: {str(e)}" + prisma_query_info = f"LiteLLM Prisma Client Exception: get_data: token={token}, table_name: {table_name}, query_type: {query_type}, user_id: {user_id}, user_id_list: {user_id_list}, team_id: {team_id}, team_id_list: {team_id_list}, key_val: {key_val}" + error_msg = prisma_query_info + str(e) print_verbose(error_msg) error_traceback = error_msg + "\n" + traceback.format_exc() + verbose_proxy_logger.debug(error_traceback) asyncio.create_task( self.proxy_logging_obj.failure_handler( original_exception=e, traceback_str=error_traceback