Enhance Makefile and update metrics handling in bot

- Added new commands in the Makefile for restarting individual services: `restart-bot`, `restart-prometheus`, and `restart-grafana`.
- Updated Prometheus and Grafana dashboard expressions for better metrics aggregation.
- Removed the `main_with_metrics.py` file and integrated metrics handling directly into the main bot file.
- Refactored middleware to improve metrics tracking and error handling across message and callback processing.
- Optimized metrics recording with enhanced bucket configurations for better performance monitoring.
This commit is contained in:
2025-08-29 18:23:17 +03:00
parent c68db87901
commit f097d69dd4
13 changed files with 166 additions and 408 deletions

View File

@@ -16,6 +16,12 @@ from .exceptions import UserNotFoundError
# Local imports - utilities
from logs.custom_logger import logger
# Local imports - metrics
from helper_bot.utils.metrics import (
metrics,
track_time,
track_errors
)
class GroupHandlers:
"""Main handler class for group messages"""
@@ -41,6 +47,7 @@ class GroupHandlers:
@error_handler
async def handle_message(self, message: types.Message, state: FSMContext):
"""Handle admin reply to user through group chat"""
logger.info(
f'Получено сообщение в группе {message.chat.title} (ID: {message.chat.id}) '
f'от пользователя {message.from_user.full_name} (ID: {message.from_user.id}): "{message.text}"'

View File

@@ -11,6 +11,14 @@ from helper_bot.utils.helper_func import send_text_message
from .exceptions import NoReplyToMessageError, UserNotFoundError
from logs.custom_logger import logger
# Local imports - metrics
from helper_bot.utils.metrics import (
metrics,
track_time,
track_errors,
db_query_time
)
class DatabaseProtocol(Protocol):
"""Protocol for database operations"""