From 170c81fc5b8ab3f79783bcca0e2129c49d2d1a9e Mon Sep 17 00:00:00 2001 From: zosimovaa Date: Thu, 26 Feb 2026 22:05:21 +0300 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=BE=D0=BB=D1=8C=D1=88=D0=BE=D0=B9=20?= =?UTF-8?q?=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D0=BD?= =?UTF-8?q?=D0=B3=20=D1=81=20=D0=BA=D0=BE=D0=B4=D0=B5=D0=BA=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 4 ++-- src/config_manager/v2/core/manager.py | 27 +++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index db90108..fa25a8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta" [project] name = "config_manager" -version = "2.2.0" -description = "Большой рефакторинг" +version = "2.2.1" +description = "Большой рефакторинг, логирование" authors = [ { name = "Aleksei Zosimov", email = "lesha.spb@gmail.com" } ] diff --git a/src/config_manager/v2/core/manager.py b/src/config_manager/v2/core/manager.py index 2b0cf4e..45e596f 100644 --- a/src/config_manager/v2/core/manager.py +++ b/src/config_manager/v2/core/manager.py @@ -89,6 +89,26 @@ class _RuntimeController: timed_out_count, ) + async def _log_health_status_transition(self) -> None: + try: + health = await self._health_aggregator.collect() + except Exception: # noqa: BLE001 + self.logger.exception("ConfigManagerV2._log_health_status_transition error") + return + status = health.get("status", "unhealthy") + if self._last_health_status == status: + return + previous = self._last_health_status or "unknown" + detail = health.get("detail", "") + self._last_health_status = status + self.logger.warning( + "ConfigManagerV2 health status changed: %s -> %s (state=%s detail=%s)", + previous, + status, + self._state.value, + detail, + ) + async def _worker_loop(self) -> None: self.logger.warning( "ConfigManagerV2._worker_loop result: started work_interval=%s", @@ -118,6 +138,7 @@ class _RuntimeController: try: while not self._halt.is_set(): await self._update_config() + await self._log_health_status_transition() try: await asyncio.wait_for(self._halt.wait(), timeout=max(self.update_interval, 0.05)) except asyncio.TimeoutError: @@ -259,6 +280,7 @@ class _RuntimeController: await self._update_config() await self._start_control_channels() await self._start_runtime() + await self._log_health_status_transition() try: await self._shutdown.wait() @@ -320,6 +342,7 @@ class ConfigManagerV2(_RuntimeController): self._worker_degraded = False self._worker_inflight_count = 0 self._worker_timed_out_inflight_count = 0 + self._last_health_status: Optional[str] = None initial_config = self._loader.load_sync() self.config = initial_config @@ -373,7 +396,7 @@ class ConfigManagerV2(_RuntimeController): self.logger.debug("ConfigManagerV2._update_config result: no changes") return self._apply_config(new_config) - self.logger.debug("ConfigManagerV2._update_config result: config updated") + self.logger.warning("ConfigManagerV2._update_config result: config updated and applied") except Exception as exc: # noqa: BLE001 self.logger.exception("ConfigManagerV2._update_config error") if self._loader.last_valid_config is None: @@ -384,7 +407,7 @@ class ConfigManagerV2(_RuntimeController): return try: self._apply_config(self._loader.last_valid_config) - self.logger.debug( + self.logger.warning( "ConfigManagerV2._update_config result: fallback to last valid config applied", ) except Exception: # noqa: BLE001