Skip to content

feat(service): each roadmap row runs in its own trace span #5415

Description

@dan-petty

Problem Description

A Service row has no trace span of its own. A trace cannot show what one row of a round did or how long it ran. The round span holds stage (36 to 75 min) and fix_plan together.

Evidence (2026-11-13): both fix_plan selection lines carry the span id of the round (96e94f4a8c6d7336 and 8404ee6e15acb620). The metric devops_cli_roadmap_row_seconds gives the seconds of each row, but a trace in Tempo cannot split a slow round by row.

Cause

  • src/devops_cli/server/service.py:680-688 opens one span service.job <repo> for each round.
  • src/devops_cli/roadmap/run.py:1631-1641 runs each row inside request_scope(row=...) with no span.

Reproduction Steps

  1. Find a fix_plan line of the Service in Loki (namespace devops), and open its trace in Tempo.
  2. The trace has the round span and the spans of requests. It has no span for the row.

Expected vs Actual Behavior

Expected: each row runs in a child span of the round, with its name, result and duration.

Actual: all rows of a round share the round span.

Environment Diagnostics

  • DevOps CLI Version: 0.128.0 (origin/main 2daf63a)
  • Execution Environment: roadmap Service in namespace devops

Proposed Fix

Open a child span service.row <name> around row.runner in run.py. Give it the attributes service.repo, service.row and service.result, and for fix_plan the mode of the row. Use the tracer of get_tracer(), as the round span does. Set the status ERROR on an exception, as the round span does. The span holds no prompt or tool content (telemetry privacy defaults).

Acceptance Criteria

  • uv run pytest tests/roadmap/test_roadmap_run_job_rows.py::test_each_row_runs_in_a_child_span_of_the_round passes: a round with two rows gives two service.row spans with the attributes.
  • uv run pytest tests/roadmap/test_roadmap_run_job_rows.py::test_a_failed_row_span_has_status_error passes.
  • uv run devops ci fail-to-pass --base origin/main shows that the two tests fail on the base and pass on the head. The pull request cites the run.
  • Live, after the merge: a Tempo search for spans named service.row fix_plan gives the spans of the Service.

Existing Tool Considered

The OpenTelemetry span API through the tracer of the project (get_tracer). No new library. Cost to build (estimate): 0.15 M tokens and 1 hour elapsed. Keep: one span for each row. Fix: about 0.05 M tokens.

Related

#5211 (the fix-plan repairs), #4576 (the repository name in logs and traces).

Source: #4843

Alternatives check of 2026-11-22: in-use.
The repository already uses this tool.
Tool: open-telemetry/opentelemetry-python (https://github.com/open-telemetry/opentelemetry-python), Apache-2.0, last activity 2026-11-20, maintained.
Reason: Searches found no alternative tool; the project already uses the OpenTelemetry span API through get_tracer, whose child spans, attributes and ERROR status cover the need, with the span wiring written in run.py and the runner entry point.

Covers:

  • Child spans under the round span through the project tracer
  • Span attributes for repo, row, result and fix_plan mode
  • ERROR status on a row that raises

Lacks:

  • No per-row span in run.py without new code
  • No service.row on runner Job root spans by itself
  • No Tempo query or dashboard of row spans

Proposed design

Problem statement

The Service gives no trace span to a row, so a slow round cannot be split by row. Add a service.row <name> child span around each row and set service.row on the runner Job root spans. The CI fail-to-pass run is the merge gate. The Tempo query is a post-merge live check.

Acceptance criteria

Requirement: Per-row child span

The Service SHALL run each due roadmap row inside a child span named service.row <name> of the round span.

Scenario: a round with two rows

  • WHEN uv run pytest tests/roadmap/test_roadmap_run_job_rows.py::test_each_row_runs_in_a_child_span_of_the_round runs a round with two rows over the OTLP fake
  • THEN the test passes, and the exported spans hold two spans named service.row <name>, each with the round span as its parent and the attributes service.repo, service.row and service.result.

Requirement: Fix-plan mode attribute

The span of the fix_plan row MUST carry the mode of the row in the attribute service.mode.

Scenario: a fix_plan row

  • WHEN uv run pytest tests/roadmap/test_roadmap_run_job_rows.py::test_the_fix_plan_row_span_carries_its_mode runs a fix_plan row with a mode over the OTLP fake
  • THEN the test passes, and the span named service.row fix_plan has the attribute service.mode set to the mode of the row.

Requirement: Error status on a failed row

A row whose runner raises an exception MUST set the status ERROR on its span.

Scenario: a failed row

  • WHEN uv run pytest tests/roadmap/test_roadmap_run_job_rows.py::test_a_failed_row_span_has_status_error runs a row whose runner raises
  • THEN the test passes, and the span named service.row <name> has status ERROR.

Requirement: Row span parent of model requests

The span of a row SHALL be the parent of each model request span that the row makes.

Scenario: a refine row with a model request

  • WHEN uv run pytest tests/roadmap/test_roadmap_run_job_rows.py::test_a_row_span_is_the_parent_of_its_model_requests runs a refine row over the OTLP fake
  • THEN the test passes, and the model request span with gen_ai.usage.input_tokens is a child of the service.row refine span.

Requirement: Runner Job root span attribute

Each runner Job that runs a roadmap row MUST set service.row on its root span.

Scenario: an implement runner Job and a fix-plan Job

  • WHEN uv run pytest tests/roadmap/test_roadmap_run_job_rows.py::test_the_implement_runner_root_span_carries_the_row and ...::test_the_fix_plan_job_root_span_carries_the_row run the runner entry point for each row over the OTLP fake
  • THEN both tests pass, and each root span has the attribute service.row set to its row name.

Requirement: Live Tempo query

The live Tempo query MUST return the row spans and the largest model request of each row.

Scenario: the refine row in Tempo

  • WHEN an operator runs the TraceQL query { name = "service.row refine" } >> { span.gen_ai.usage.input_tokens > 0 } | max_over_time(span.gen_ai.usage.input_tokens) in Tempo after the merge
  • THEN the query returns the service.row refine spans and the largest gen_ai.usage.input_tokens of each span.

Requirement: Fail-to-pass proof

The pull request MUST show that the new tests fail on the base and pass on the head.

Scenario: the fail-to-pass run

  • WHEN the pull request runs uv run devops ci fail-to-pass --base origin/main
  • THEN the command reports that the new tests fail on the base and pass on the head, and the pull request cites the run.

Existing Tool Considered

open-telemetry/opentelemetry-python (https://github.com/open-telemetry/opentelemetry-python) - verdict in-use (alternatives check of 2026-11-17 in the issue body). The item already names the OpenTelemetry span API through get_tracer(), and the repository already uses the library. The check lists what the tool covers and lacks.

This change opens the service.row <name> child span around row.runner in run.py. It sets the attributes in code. That is the first part the check says the library does not give for free.

It also sets service.row on the root span of the implement runner and fix-plan Jobs. That is the second part the check says no instrumentation does automatically. The issue estimates 0.15 M tokens and 1 hour for the span code, and 0.05 M tokens to fix it.

Key questions

  • What is the attribute name for the fix_plan mode?: service.mode. The span attributes use the service. prefix, so the mode follows them. (best practice) [sources: src/devops_cli/server/service.py, src/devops_cli/roadmap/run.py]
    • Chosen: service.mode. It follows the service. prefix of service.repo, service.row and service.result.
    • Rejected: fix_plan.mode. It mixes a row name into the attribute namespace and breaks the prefix.
    • Rejected: roadmap.mode. It does not match the service. prefix of the other span attributes.
  • Should the row span be the current span so the model request spans are children?: Yes. Open the span with the tracer's context manager around row.runner, so the AI client's model request spans are children of the row span. (best practice) [sources: src/devops_cli/telemetry/tracer.py, src/devops_cli/ai/client/unified.py, src/devops_cli/roadmap/run.py]
    • Chosen: current span around row.runner. The AI client reads the current span context, so the model request spans become children.
    • Rejected: start a span without making it current. The model request spans would not be children, so the TraceQL query would not work.
    • Rejected: pass the span context explicitly. It adds code to each call and duplicates the context manager.
  • Where do the runner Jobs set service.row on their root span?: At the runner entry point that starts the implement and fix-plan Jobs. The entry point sets service.row on the root span it already opens. (best practice) [sources: src/devops_cli/main.py, src/devops_cli/roadmap/agent_run.py]
    • Chosen: runner entry point. The root span of the Job is in the runner pod, so the row name must be set there.
    • Rejected: Service Job-creation span. That span is in the Service, not in the Job, so it cannot be the Job's root span.
  • Does the span record prompt or tool content?: No. It records only service.repo, service.row, service.result and, for fix_plan, service.mode. The telemetry privacy defaults stay. (best practice) [sources: docs/TELEMETRY.md, src/devops_cli/telemetry/tracer.py]
    • Chosen: attributes only. The issue requires the telemetry privacy defaults and no prompt or tool content.
    • Rejected: record the row's input. It would put prompt or tool content in a span and break the privacy defaults.
  • Is the live Tempo query a merge gate?: No. The CI fail-to-pass run is the merge gate. The Tempo query is a post-merge live check, because it needs the deployed Service and the merged span. (best practice) [sources: docs/adr/0004-ci-is-the-authoritative-gate.md, docs/TELEMETRY.md]
    • Chosen: post-merge live check. The query needs the deployed Service and the merged code, so it cannot run before the merge.
    • Rejected: merge gate. It cannot pass before the merge, so it would block every pull request.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 13, 2026
  2. added
    type/feature
    scope/service
    status/new
    value/medium
    effort/low
    on Nov 13, 2026
  3. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 13, 2026
  5. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    A second need for this span (2026-11-13). The owner moves each model slot (ai.tasks.<slot>) to the local qwen3.8:27b when every job of the slot is above 90% and its largest request stays under 256k input tokens.

    Today a trace cannot give the context size of one job:

    • the model request spans carry gen_ai.usage.input_tokens;
    • gen_ai.agent.name is always agent;
    • the span attribute job holds only the name of a runner Job.

    So I measured only intake, through the ModelProposal schema span: at most about 4.3k input tokens in 24 h. Refine, alternatives and the consolidate judge share the analysis slot, and none of them can be measured.

    Please add to the acceptance criteria:

    • The TraceQL query { name = "service.row refine" } >> { span.gen_ai.usage.input_tokens > 0 } | max_over_time(span.gen_ai.usage.input_tokens) gives the largest request of the refine row. The same works for every row.
    • The Jobs that run a row (the implement runner and fix-plan) set service.row on their root span, so the same query works for them.
  6. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The need is per-row trace spans under the existing round span, and the issue already names the OpenTelemetry span API through the project's get_tracer() as the tool, with no new library. The OpenTelemetry Python API provides exactly this: named child spans from a tracer, arbitrary span attributes, and an error span status, so nothing else has to be introduced.

    The repository already uses this tool.

    Tool: open-telemetry/opentelemetry-python (https://github.com/open-telemetry/opentelemetry-python)

    • License: Apache-2.0
    • Last activity: 2026-11-15
    • Maintained: yes

    Covers:

    • A tracer starts a named span, so each row can get a service.row <name> child span of the round span
    • Span attributes, so service.repo, service.row, service.result and the fix_plan mode are recorded on the span
    • Status can be set to ERROR on an exception, as the round span already does
    • Span attributes are exported with the span, so a Tempo TraceQL query can filter and aggregate on them (e.g. service.row with gen_ai.usage.input_tokens)
    • The tracer of the project (get_tracer()) is reused, so the span joins the existing trace with no new dependency

    Lacks:

    • The library gives no row-span for free: the span still has to be opened around row.runner in run.py and the attributes set in code
    • The runner Jobs (implement runner, fix-plan) must set service.row on their root span themselves; no instrumentation does that automatically
    • The Tempo side (TraceQL queries, span naming in search) is the backend's behaviour, not part of the library

    Tools considered:

    Searches run:

    • OpenTelemetry Python create custom child span with attributes and error status, results: 5
    • opentelemetry-python tracer start_as_current_span set_status StatusCode.ERROR, results: 5
    • opentelemetry-python GitHub repository traces API, results: 5
    • OpenTelemetry tracing Python documentation spans nested parent child, results: 5
    • open-telemetry opentelemetry-python, results: 5
    • opentelemetry.io Python manual instrumentation spans, results: 5
    • TraceQL query span attribute Grafana Tempo documentation, results: 5

    Sources:

    Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.

  7. added
    status/ready
    and removed
    status/new
    on Nov 17, 2026
  8. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 2620fae (see proposed design in issue body).

  9. added
    status/in-progress
    and removed
    status/ready
    on Nov 25, 2026
  10. added a commit that references this issue on Nov 25, 2026
    8e56c1e
  11. added
    status/in-review
    and removed
    status/in-progress
    on Nov 25, 2026
  12. removed
    status/in-review
    on Nov 25, 2026
  13. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor
  14. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-25 06:46 UTC

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/servicesource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions