|
| 1 | +--- |
| 2 | +title: Add TaskManager metrics for task tracking |
| 3 | +status: closed |
| 4 | +priority: 2 |
| 5 | +issue_type: task |
| 6 | +depends_on: |
| 7 | + scotty-06fec: blocks |
| 8 | +created_at: 2025-10-25T00:37:07.454119+00:00 |
| 9 | +updated_at: 2025-11-24T20:17:25.572273+00:00 |
| 10 | +closed_at: 2025-10-25T13:29:19.632177+00:00 |
| 11 | +--- |
| 12 | + |
| 13 | +# Description |
| 14 | + |
| 15 | +Instrument TaskManager to track number of tasks, their states (running/finished/failed), durations, and success rates. |
| 16 | + |
| 17 | +# Design |
| 18 | + |
| 19 | +Add TaskManager metrics to ScottyMetrics struct: |
| 20 | +- tasks_total (Counter) - Total tasks created |
| 21 | +- tasks_by_state (Gauge) - Current tasks grouped by state labels: |
| 22 | + * state="running" |
| 23 | + * state="finished" |
| 24 | + * state="failed" |
| 25 | +- task_duration_seconds (Histogram) - Task execution time |
| 26 | +- task_failures_total (Counter) - Failed tasks counter |
| 27 | + |
| 28 | +Implementation approach: |
| 29 | +1. Add metrics to scotty/src/metrics/instruments.rs |
| 30 | +2. Instrument scotty/src/tasks/manager.rs: |
| 31 | + - add_task(): increment tasks_total, update state gauge |
| 32 | + - set_task_finished(): update state gauges, record duration histogram |
| 33 | + - Optional: background sampler every 30s to sync gauges with HashMap state |
| 34 | + |
| 35 | +Data sources: |
| 36 | +- TaskManager.processes HashMap size = total active tasks |
| 37 | +- TaskDetails.state: Running | Finished | Failed |
| 38 | +- TaskDetails.start_time + finish_time for duration calculation |
| 39 | +- TaskDetails.last_exit_code for success/failure tracking |
| 40 | + |
| 41 | +# Acceptance Criteria |
| 42 | + |
| 43 | +- Task metrics exported to OTLP |
| 44 | +- Metrics accurately reflect task states |
| 45 | +- Duration tracking works correctly |
| 46 | +- Failed vs successful tasks distinguishable |
| 47 | +- Dashboard panels created for task monitoring |
| 48 | +- No performance degradation |
0 commit comments