Add step / task / workflow run / observer metrics as logs (#1698)

Co-authored-by: Suchintan <suchintan@users.noreply.github.com>
This commit is contained in:
Shuchang Zheng
2025-02-02 03:10:38 +08:00
committed by GitHub
parent 41e8d8b0ac
commit 204972e225
11 changed files with 284 additions and 219 deletions

View File

@@ -1,5 +1,6 @@
import asyncio
import json
from datetime import UTC, datetime
from typing import Any
import httpx
@@ -468,6 +469,18 @@ class WorkflowService:
browser_session_id=browser_session_id,
close_browser_on_completion=browser_session_id is None,
)
# Track workflow run duration when completed
duration_seconds = (datetime.now(UTC) - workflow_run.created_at).total_seconds()
LOG.info(
"Workflow run duration metrics",
workflow_run_id=workflow_run_id,
workflow_id=workflow_run.workflow_id,
duration_seconds=duration_seconds,
status=WorkflowRunStatus.completed,
organization_id=organization_id,
)
return workflow_run
async def create_workflow(