Refactor metrics handling and improve logging

- Removed the MetricsManager initialization from `run_helper.py` to avoid duplication, as metrics are now handled in `main.py`.
- Updated logging levels in `server_prometheus.py` and `metrics_middleware.py` to use debug instead of info for less critical messages.
- Added metrics configuration to `BaseDependencyFactory` for better management of metrics settings.
- Deleted the obsolete `metrics_exporter.py` file to streamline the codebase.
- Updated various tests to reflect changes in the metrics handling and ensure proper functionality.
This commit is contained in:
2025-09-03 00:33:20 +03:00
parent 6fcecff97c
commit c8c7d50cbb
19 changed files with 402 additions and 605 deletions

View File

@@ -29,7 +29,7 @@ class MetricsServer:
async def metrics_handler(self, request: web.Request) -> web.Response:
"""Handle /metrics endpoint for Prometheus scraping."""
try:
self.logger.info("Generating metrics...")
self.logger.debug("Generating metrics...")
# Проверяем, что metrics доступен
if not metrics:
@@ -40,9 +40,8 @@ class MetricsServer:
)
# Генерируем метрики в формате Prometheus
self.logger.info("Calling metrics.get_metrics()...")
metrics_data = metrics.get_metrics()
self.logger.info(f"Generated metrics: {len(metrics_data)} bytes")
self.logger.debug(f"Generated metrics: {len(metrics_data)} bytes")
return web.Response(
body=metrics_data,