Skip to content

Phase C: Wire experiment_* metrics to populate experiment-tracking dashboard #1243

Description

@geoffjay

Goal

The Grafana dashboard infra/grafana/dashboards/experiment-tracking.json references three metrics that no code emits:

  • experiment_dispatches_total{experiment, status}
  • experiment_cost_usd_total{experiment}
  • experiment_dispatch_duration_seconds_bucket{experiment}

Result: the dashboard is permanently empty. User has confirmed experiments is a planned feature. Wire the metrics so the dashboard works.

Tasks

1. Locate the experiment dispatch path

Experiments are not yet a first-class concept in the codebase. Likely entry points to check:

  • crates/orchestrator/src/scheduler/ — experiments may live alongside workflows
  • Workflow metadata — check whether WorkflowResponse has an experiment field
  • Any prompt template variables that label dispatches with an experiment ID

If experiments don't exist yet as a concept: this issue may need to be re-scoped as "add experiment tracking" rather than just emitting the metrics.

2. Emit the three metrics

// On dispatch completion
metrics::counter!("experiment_dispatches_total",
    "experiment" => experiment_id,
    "status" => status_label, // "dispatched" | "failed"
).increment(1);

metrics::counter!("experiment_cost_usd_total",
    "experiment" => experiment_id,
).increment_by(cost_usd);

metrics::histogram!("experiment_dispatch_duration_seconds",
    "experiment" => experiment_id,
).record(duration_secs);

Cardinality note: experiment label is bounded by the number of distinct experiments — acceptable if experiments are limited (≤ 100s). If experiments can grow unbounded, consider hashing/bucketing.

3. Validate the dashboard

Open experiment-tracking.json in Grafana with Prometheus connected and confirm all panels render data.

Files Touched

  • crates/orchestrator/src/scheduler/runner.rs (or wherever dispatch happens)
  • Possibly crates/orchestrator/src/types.rs if experiment becomes a workflow field

Verification

  1. Run an experiment dispatch (mechanism TBD based on discovery in task 1)
  2. curl localhost:17006/metrics | grep experiment_ shows the three metrics
  3. Grafana panels in experiment-tracking.json show non-empty time series

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity:mediumMedium scope: <200 lines, 1-2 filesenhancementNew feature or requestneeds-refinementIssue needs enrichment and additional context before implementationtriagedIssue has been triaged, ready for planning or implementation

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions