Skip to content

Add GET /api/workflows/{workflow_id}/metrics endpoint for workflow analytics#161

Closed
akgohain wants to merge 1 commit intomainfrom
codex/add-metrics-endpoint-for-workflows-9pu451
Closed

Add GET /api/workflows/{workflow_id}/metrics endpoint for workflow analytics#161
akgohain wants to merge 1 commit intomainfrom
codex/add-metrics-endpoint-for-workflows-9pu451

Conversation

@akgohain
Copy link
Copy Markdown
Collaborator

Motivation

  • Provide a backend endpoint to surface workflow-stage and agent-action analytics as a stable API for monitoring and UI consumption.
  • Ensure the endpoint returns safe defaults when a workflow has sparse or no events and produce a stable response schema for downstream consumers.

Description

  • Add a new workflow router at server_api/workflow/metrics.py that implements GET /api/workflows/{workflow_id}/metrics and a _compute_workflow_metrics helper to derive analytics from an in-memory workflow_events store.
  • The metrics computed include event counts by type, approval/rejection counts and rates, stage transition counts formatted as from->to, and first/last event timestamps (ISO8601), with safe defaults when events are absent.
  • Wire the new router into the app by including it in server_api/main.py and add focused unit tests in tests/test_workflow_metrics.py covering empty workflows and seeded event scenarios.
  • An example API schema (returned JSON) is included with the change and follows the shape: {"workflow_id","event_total","metrics": {"event_counts", "approvals", "stage_transitions", "timeline"}}.

Testing

  • Ran uv run pytest -q tests/test_workflow_metrics.py, which failed in this environment due to an editable dependency metadata issue for pytorch_connectomics (package metadata generation error).
  • Ran PYTHONPATH=. pytest -q tests/test_workflow_metrics.py, which executed the new tests successfully and reported 2 passed.

Codex Task

@akgohain
Copy link
Copy Markdown
Collaborator Author

Consolidated into draft PR #165 (feat/codex-wave-integration). Closing this source draft to keep review in one place.

@akgohain akgohain closed this Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant