уровень debug в trace

This commit is contained in:
2026-03-07 18:14:47 +03:00
parent 93e9f4c37e
commit 79b0e72abb
4 changed files with 23 additions and 7 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ from datetime import datetime, timezone
from typing import Any, Literal, Protocol
TraceLevel = Literal["INFO", "WARNING", "ERROR"]
TraceLevel = Literal["DEBUG", "INFO", "WARNING", "ERROR"]
def utc_now() -> datetime:
+3
View File
@@ -90,6 +90,9 @@ class TraceService(TraceContextFactory):
def info(self, message: str, *, status: str | None = None, attrs: dict[str, Any] | None = None) -> None:
self._write_message("INFO", message, status, attrs)
def debug(self, message: str, *, status: str | None = None, attrs: dict[str, Any] | None = None) -> None:
self._write_message("DEBUG", message, status, attrs)
def warning(self, message: str, *, status: str | None = None, attrs: dict[str, Any] | None = None) -> None:
self._write_message("WARNING", message, status, attrs)
@@ -34,7 +34,11 @@ class WorkflowEngine:
self._hooks.on_step_started(context, current_name)
self._persistence.start_step(run_id, current_name, context.snapshot())
self._traces.step(current_name)
self._traces.info(f"Step '{current_name}' started.", status="started")
self._traces.debug(
f"Step '{current_name}' started.",
status="started",
attrs={"workflow_run_id": run_id, "node": current_name},
)
try:
result = node.step.run(context)
except Exception as error:
@@ -56,9 +60,16 @@ class WorkflowEngine:
result.transition,
context.snapshot(),
)
self._traces.info(
next_node = self._transition_resolver.resolve(node, result)
self._traces.debug(
f"Step '{current_name}' completed with transition '{result.transition}'.",
status=result.status,
attrs={
"workflow_run_id": run_id,
"from_node": current_name,
"transition": result.transition,
"to_node": next_node,
},
)
self._logger.info(
"Workflow run %s: step '%s' completed with transition '%s'.",
@@ -67,7 +78,7 @@ class WorkflowEngine:
result.transition,
)
self._hooks.on_step_finished(context, current_name)
current_name = self._transition_resolver.resolve(node, result)
current_name = next_node
self._persistence.complete_run(run_id, context.snapshot())
self._traces.step("workflow")
self._traces.info("Workflow completed.", status="completed", attrs={"workflow_run_id": run_id})