Правки

This commit is contained in:
2026-03-07 17:21:27 +03:00
parent e055a6a09e
commit 93e9f4c37e
7 changed files with 347 additions and 168 deletions

View File

@@ -259,6 +259,38 @@ def test_trace_service_writes_contexts_and_messages() -> None:
assert transport.messages[0].step == "parse"
def test_trace_service_supports_warning_and_error_levels() -> None:
from app_runtime.tracing.service import TraceService
transport = RecordingTransport()
manager = TraceService(transport=transport)
with manager.open_context(alias="worker", kind="worker", attrs={"routine": "incoming"}):
manager.step("validate")
manager.warning("validation warning", status="degraded", attrs={"attempt": 1})
manager.error("integration failed", status="failed", attrs={"integration": "crm"})
manager.exception("caught exception", attrs={"exception_type": "RuntimeError"})
levels = [message.level for message in transport.messages]
assert levels == ["WARNING", "ERROR", "ERROR"]
def test_trace_service_allows_messages_without_status() -> None:
from app_runtime.tracing.service import TraceService
transport = RecordingTransport()
manager = TraceService(transport=transport)
with manager.open_context(alias="worker", kind="worker"):
manager.step("optional-status")
manager.info("info without status")
manager.warning("warning without status")
manager.error("error without status")
assert [message.status for message in transport.messages] == ["", "", ""]
assert all(message.trace_id == transport.contexts[0].trace_id for message in transport.messages)
def test_http_control_channel_exposes_health_and_actions() -> None:
from app_runtime.control.base import ControlActionSet
from app_runtime.control.http_channel import HttpControlChannel