Skip to content

Migrate Workflow Metrics to Prometheus Histograms #82

Closed

Description

@mrveiss

Parent Issue

Part of #80 - Epic: Consolidate All Monitoring Systems into Prometheus + Grafana

Current State

src/metrics/workflow_metrics.py collects:

  • Workflow execution duration
  • Step-by-step timings
  • Success/failure rates per complexity
  • Agent usage counts
  • Error tracking per workflow
  • Resource usage snapshots
  • Approval wait times

Data stored in-memory with max 10,000 metrics history.

Goal

Export workflow metrics to Prometheus using histograms and counters for percentile calculations and trend analysis.

Implementation

1. Add Prometheus Metrics

# Workflow execution metrics
autobot_workflow_duration_seconds = Histogram(
    'autobot_workflow_duration_seconds',
    'Workflow execution duration',
    ['workflow_type', 'complexity'],
    buckets=[0.1, 0.5, 1.0, 2.5, 5.0, 10.0, 30.0, 60.0, 120.0]
)

autobot_workflow_total = Counter(
    'autobot_workflow_total',
    'Total workflows executed',
    ['workflow_type', 'status']  # status: success, failure, timeout
)

autobot_workflow_steps_total = Counter(
    'autobot_workflow_steps_total',
    'Total workflow steps executed',
    ['step_type']
)

# Agent usage
autobot_agent_usage_total = Counter(
    'autobot_agent_usage_total',
    'Agent usage count',
    ['agent_type']
)

# Approval metrics
autobot_approval_wait_seconds = Histogram(
    'autobot_approval_wait_seconds',
    'Time waiting for approvals',
    buckets=[1, 5, 10, 30, 60, 120, 300]
)

2. Integration Points

  • Hook into WorkflowMetricsCollector.record_workflow_completion()
  • Update Prometheus metrics in real-time
  • Maintain in-memory buffer for backward compatibility

3. Benefits

  • Automatic percentile calculations (p50, p95, p99)
  • Long-term trend analysis
  • Alerting on slow workflows via AlertManager

Acceptance Criteria

  • Workflow duration tracked as histogram
  • Success/failure rates as counters with labels
  • Agent usage tracked per agent type
  • Step timings aggregated properly
  • Grafana can show workflow performance trends
  • Alerting possible on workflow duration thresholds

Files to Modify

  • src/monitoring/prometheus_metrics.py - Add workflow metric definitions
  • src/metrics/workflow_metrics.py - Integrate Prometheus export
  • src/core/workflow_engine.py - Ensure metrics are emitted

Labels: enhancement, monitoring, metrics

Activity

  1. mrveiss commented on Dec 5, 2025

    @mrveiss
    OwnerAuthor

    ✅ Complete as part of Epic #80. All monitoring consolidated into Prometheus + Grafana. See Epic #80 for full details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions