Skip to content

Add workflow metrics endpoint and aggregation with tests#159

Closed
akgohain wants to merge 1 commit into
mainfrom
codex/add-metrics-endpoint-for-workflows-swwsej
Closed

Add workflow metrics endpoint and aggregation with tests#159
akgohain wants to merge 1 commit into
mainfrom
codex/add-metrics-endpoint-for-workflows-swwsej

Conversation

@akgohain
Copy link
Copy Markdown
Collaborator

Motivation

  • Provide a backend endpoint to expose workflow-stage and agent-action analytics to consumers via a stable schema.
  • Compute common metrics (event counts, approvals/rejections, transitions, timestamps) for operational visibility and reporting.
  • Ensure the endpoint behaves predictably when no or sparse events exist by returning safe defaults.

Description

  • Added server_api/workflow/metrics.py which implements compute_workflow_metrics and helper timestamp parsing/formatting functions.
  • Added server_api/workflow/router.py exposing GET /api/workflows/{workflow_id}/metrics that reads events from app.state.workflow_events_store and returns {"workflow_id", "metrics"}.
  • Wired the workflow router into the main app by including the router in server_api/main.py so the endpoint is mounted at runtime.
  • Added tests/test_workflow_metrics.py which validates the response schema, safe defaults for empty event lists, and correctness against seeded events.

Testing

  • Attempted the requested run uv run pytest -q tests/test_workflow_metrics.py which failed in this environment due to editable pytorch_connectomics package metadata resolution.
  • Run the focused test set with PYTHONPATH=. pytest -q tests/test_workflow_metrics.py and all tests passed (3 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