Add step / task / workflow run / observer metrics as logs (#1698)
Co-authored-by: Suchintan <suchintan@users.noreply.github.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user