-
Notifications
You must be signed in to change notification settings - Fork 43
Add workflow health monitoring command with cost metrics (gh aw health) #12662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot show cost |
- Add TokenUsage and EstimatedCost fields to WorkflowHealth struct - Calculate average tokens and cost in CalculateWorkflowHealth - Display cost metrics in summary and detailed views - Add formatTokens and formatCost helper functions - Add tests for new formatting functions - Show average cost per run and total cost in detailed view Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added cost metrics to the health command in commit bb9b233. The health command now displays: Summary view includes two new columns:
Detailed view shows three cost metrics:
Example output: All metrics are included in JSON output for programmatic consumption. |
|
@copilot use console package helpers to build table |
- Remove manual separator lines (━━━━━) - Remove redundant icons (console.Format* functions add them automatically) - Simplify output formatting to rely on console helpers - Consistent with other CLI commands (list, status, audit) Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated in commit 4eed7b3 to use console package helpers consistently:
The health command now uses console helpers exclusively for all output formatting. |
Workflow Health Dashboard Command Implementation ✅
This PR implements the
gh aw healthcommand for workflow health monitoring as described in issue #12540.✅ All Implementation Tasks Completed
health_command.gowith command structure and flagshealth_metrics.gowith health calculation logicChanges Made
pkg/cli/health_command.go (300 lines)
NewHealthCommand(): Command structure with flagsRunHealth(): Main execution logic with config validationfetchWorkflowRuns(): GitHub API integration with paginationdisplayHealthSummary(): Summary view for all workflowsdisplayDetailedHealth(): Detailed view with cost metricsoutputHealthJSON(),outputHealthTable(): Output formatting using console helperspkg/cli/health_metrics.go (320 lines)
WorkflowHealth: Struct with health + cost metricsHealthSummary: Struct for aggregated metricsTrendDirection: Enum with visual indicators (↑→↓)CalculateWorkflowHealth(): Main health + cost calculationcalculateTrend(): Trend detection algorithmformatDuration(): Duration formattingformatTokens(): Token count formatting (K/M notation)formatCost(): Cost formatting with precisionpkg/cli/health_metrics_test.go (420 lines)
TestCalculateWorkflowHealth: Health calculation testsTestCalculateTrend: Trend detection testsTestFormatDuration: Duration formatting testsTestFormatTokens: Token formatting testsTestFormatCost: Cost formatting testsTestGroupRunsByWorkflow: Data grouping testsTestFilterWorkflowsByName: Data filtering testsTestCalculateHealthSummary: Summary calculation testspkg/cli/health_command_test.go (90 lines)
TestHealthConfigValidation: Config validation testsTestHealthCommand: Command structure testscmd/gh-aw/main.go
Features Delivered
✅ Summary View: All workflows with success rates sorted by health
✅ Detailed View: Individual workflow metrics
✅ Historical Analysis: 7/30/90 days configurable
✅ Trend Detection: ↑ improving, → stable, ↓ degrading
✅ Threshold Alerting: Default 80%, configurable
✅ JSON Output: For programmatic consumption
✅ Console Rendering: Uses console.RenderStruct() helpers
✅ Error Handling: Clear error messages
✅ GitHub API Integration: Paginated workflow run fetching
✅ Cost Metrics: Token usage and estimated cost per workflow
✅ Test Coverage: 9 test functions, 30+ test cases
Command Examples
Example Output
Summary View:
Detailed View:
Testing
Code Quality
console.RenderStruct()for table rendering (consistent with list, status, audit commands)console.Format*Message()helpers for all user-facing messagesPriority & Impact
Priority: High
Impact: Provides proactive workflow health monitoring with cost visibility, prevents user-reported issues, enables early detection of degrading workflows
Related
Closes #12540
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.