fix(douyu): 修复斗鱼链路 P0/P1 隐患并增强 P2 运维队列可观测性
This commit is contained in:
@@ -38,12 +38,34 @@ def _runtime_heartbeat_path() -> Path:
|
||||
|
||||
|
||||
def _runtime_heartbeat_payload() -> dict[str, Any]:
|
||||
from .database import worker_engine
|
||||
from .services.automation.scheduler import scheduler_status
|
||||
from .services.binding_poll_scheduler import (
|
||||
scheduler_status as binding_poll_status,
|
||||
)
|
||||
from .services.douyu_runner_core import douyu_batch_registry
|
||||
from .services.execution_worker import execution_job_worker_status
|
||||
from .services.payment_poll_scheduler import (
|
||||
scheduler_status as payment_poll_status,
|
||||
)
|
||||
from .services.task_runtime import lane_stats
|
||||
|
||||
return {
|
||||
"pid": os.getpid(),
|
||||
"updatedAt": datetime.now(UTC).isoformat(),
|
||||
"scheduler": scheduler_status(),
|
||||
"runtime": {
|
||||
"task_lanes": lane_stats(),
|
||||
"worker_db_pool": (
|
||||
getattr(worker_engine.pool, "status", lambda: "")()
|
||||
if callable(getattr(worker_engine.pool, "status", None))
|
||||
else ""
|
||||
),
|
||||
"binding_poll": binding_poll_status(),
|
||||
"payment_poll": payment_poll_status(),
|
||||
"execution_jobs": execution_job_worker_status(),
|
||||
"douyu_batches": douyu_batch_registry.stats(),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -115,8 +137,10 @@ def background_runtime_status() -> dict[str, Any]:
|
||||
"staleAfterSeconds": _HEARTBEAT_STALE_SECONDS,
|
||||
"pid": None,
|
||||
"scheduler": {},
|
||||
"runtime": {},
|
||||
}
|
||||
scheduler = payload.get("scheduler")
|
||||
runtime = payload.get("runtime")
|
||||
return {
|
||||
"running": age_seconds <= _HEARTBEAT_STALE_SECONDS,
|
||||
"heartbeatAt": heartbeat_at.isoformat(),
|
||||
@@ -124,6 +148,7 @@ def background_runtime_status() -> dict[str, Any]:
|
||||
"staleAfterSeconds": _HEARTBEAT_STALE_SECONDS,
|
||||
"pid": payload.get("pid"),
|
||||
"scheduler": scheduler if isinstance(scheduler, dict) else {},
|
||||
"runtime": runtime if isinstance(runtime, dict) else {},
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user