From d22483770efc84e652212f009dd8444d2aa535ec Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 28 Jun 2024 14:07:54 +0500 Subject: [PATCH] Monitoring added into Http Loops --- smart_kit/start_points/main_loop_async_http.py | 1 + smart_kit/start_points/main_loop_http.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/smart_kit/start_points/main_loop_async_http.py b/smart_kit/start_points/main_loop_async_http.py index 0d92ed50..fcf2cf09 100644 --- a/smart_kit/start_points/main_loop_async_http.py +++ b/smart_kit/start_points/main_loop_async_http.py @@ -164,6 +164,7 @@ async def process_message(self, message: SmartAppFromMessage, *args, **kwargs): stats += "Script time: {} msecs\n".format(script_timer.msecs) with StatsTimer() as save_timer: await self.save_user(db_uid, user, message) + monitoring.sampling_save_time(self.app_name, save_timer.secs) stats += "Saving time: {} msecs\n".format(save_timer.msecs) log(stats, params={log_const.KEY_NAME: "timings"}) await self.postprocessor.postprocess(user, message) diff --git a/smart_kit/start_points/main_loop_http.py b/smart_kit/start_points/main_loop_http.py index 6d677b83..4aa73b0d 100644 --- a/smart_kit/start_points/main_loop_http.py +++ b/smart_kit/start_points/main_loop_http.py @@ -9,6 +9,7 @@ from core.configs.global_constants import CALLBACK_ID_HEADER from core.logging.logger_utils import log from core.message.from_message import SmartAppFromMessage, basic_error_message +from core.monitoring.monitoring import monitoring from core.utils.stats_timer import StatsTimer from smart_kit.compatibility.commands import combine_commands from smart_kit.message.smartapp_to_message import SmartAppToMessage @@ -81,6 +82,7 @@ def process_message(self, message: SmartAppFromMessage, *args, **kwargs): stats += "Script time: {} msecs\n".format(script_timer.msecs) with StatsTimer() as save_timer: self.loop.run_until_complete(self.save_user(db_uid, user, message)) + monitoring.sampling_save_time(self.app_name, save_timer.secs) stats += "Saving time: {} msecs\n".format(save_timer.msecs) log(stats, user=user, params={log_const.KEY_NAME: "timings"}) self.loop.run_until_complete(self.postprocessor.postprocess(user, message)) @@ -111,6 +113,7 @@ def _generate_answers(self, user, commands, message, **kwargs): "+ behavior, продолжающий сценарий.") answer = commands.pop() if commands else None + monitoring.counter_outgoing(self.app_name, answer.name, answer, user) return answer