Skip to content

Add workflow metrics endpoint with analytics and tests#158

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

Add workflow metrics endpoint with analytics and tests#158
akgohain wants to merge 1 commit intomainfrom
codex/add-metrics-endpoint-for-workflows

Conversation

@akgohain
Copy link
Copy Markdown
Collaborator

Motivation

  • Provide a backend endpoint to expose workflow-stage and agent-action analytics for observability and downstream UI/consumers.
  • Produce aggregate metrics (event counts by type, approval/rejection counts and rates, stage transition counts, and first/last event timestamps) from workflow event histories.
  • Ensure the endpoint returns safe defaults when workflows have sparse or no events so callers get a stable schema.

Description

  • Added a new router GET /api/workflows/{workflow_id}/metrics in server_api/workflow/router.py with an in-memory seeding helper seed_workflow_events for deterministic tests.
  • Implemented compute_workflow_metrics in server_api/workflow/metrics.py to aggregate event type counts, decision metrics (approvals/rejections and rates), stage transition counts, first/last timestamps, and total events while returning safe defaults for empty inputs.
  • Exported the router from server_api/workflow/__init__.py so it can be mounted by applications.
  • Added test coverage in tests/test_workflow_metrics.py asserting empty-workflow defaults, correctness against seeded events, and a stable response schema for missing workflows.

Testing

  • Ran python -m pytest -q tests/test_workflow_metrics.py which completed successfully with 3 passed.
  • Attempted uv run pytest -q tests/test_workflow_metrics.py but it failed due to an editable package metadata issue for pytorch_connectomics in this environment (packaging metadata error); this did not affect the targeted unit tests which passed under python -m pytest.
  • All new endpoint-focused tests added in tests/test_workflow_metrics.py passed under the working test runner.

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