Skip to content

Commit

Permalink
Monitoring added into Http Loops
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan committed Jun 28, 2024
1 parent 7eb77fb commit d224837
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions smart_kit/start_points/main_loop_async_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions smart_kit/start_points/main_loop_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit d224837

Please sign in to comment.