feat: add OpenTelemetry task and operation IDs to agent telemetry spans - #261
Merged
Merged
Conversation
The runner emitted no parent span for an agent loop run, so tool spans landed as orphan siblings in Tempo: a single failing task could not be recovered as one trace, only as a fan of unrelated spans. Worse, four call sites passed `task_id` into the helpers' `operation_id` parameter (runner.rs:311 et al.), so the `attack_operation_id` field on tool spans actually held a task ID — silently breaking any dashboard that filtered by operation. - Open `agent.loop` once at the top of run_agent_loop, carrying op.id, task.id, agent.role, agent.model. Move the existing body into run_agent_loop_inner and instrument the future with that span; every child span now inherits the parent. - Add `task_id` to AgentSpanBuilder + the four trace_* helpers and emit `op.id` / `task.id` alongside the existing `attack_operation_id` field for back-compat with current dashboards. - Fix the four runner.rs sites that were passing task_id where operation_id was expected, and pass real op.id and task.id to the worker discovery span and the orchestrator domain-admin span. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #261 +/- ##
==========================================
+ Coverage 75.10% 75.13% +0.02%
==========================================
Files 383 383
Lines 81465 81570 +105
==========================================
+ Hits 61187 61286 +99
- Misses 20278 20284 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
**Changed:** - Updated function calls in run_agent_loop_inner to pass op_id as a value (Some(op_id)) instead of as a reference (Some(&op_id)) to match expected parameter types and avoid potential lifetime or type mismatch issues in agent_loop/runner.rs
l50
added a commit
that referenced
this pull request
May 9, 2026
…ns (#261) **Key Changes:** - Added `op.id` and `task.id` fields to all agent-related telemetry spans for improved correlation and traceability - Updated agent loop and tool execution logic to propagate and emit these identifiers - Refactored span builder and helper functions to support the new identifiers throughout the codebase **Added:** - `op.id` and `task.id` span attributes to all relevant agent, decision, tool call, discovery, and milestone telemetry spans for OpenTelemetry compatibility and enhanced query/filter capabilities - `task_id` field to the `AgentSpanBuilder` struct and corresponding builder method for consistent span construction - Internal helper function `resolve_operation_id_from_env` in agent loop runner to reliably extract operation ID from environment variables **Changed:** - Refactored agent loop runner (`ares-llm/src/agent_loop/runner.rs`) to nest all agent task execution under a parent span containing `op.id` and `task.id` - Updated span creation in milestones, tool execution, and decision-making to include both operation and task identifiers - Modified span builder and helper functions (`ares-core/src/telemetry/spans/builder.rs`, `helpers.rs`) to accept and propagate the new identifiers as needed - Updated test cases in span module to verify presence of new attributes in spans - Updated GitHub Actions workflows to use the latest versions of `actions/upload-artifact` and `actions/setup-go` - Updated Semgrep workflow to use a new container image version for improved security and compatibility ---------
l50
added a commit
that referenced
this pull request
May 9, 2026
…ns (#261) **Key Changes:** - Added `op.id` and `task.id` fields to all agent-related telemetry spans for improved correlation and traceability - Updated agent loop and tool execution logic to propagate and emit these identifiers - Refactored span builder and helper functions to support the new identifiers throughout the codebase **Added:** - `op.id` and `task.id` span attributes to all relevant agent, decision, tool call, discovery, and milestone telemetry spans for OpenTelemetry compatibility and enhanced query/filter capabilities - `task_id` field to the `AgentSpanBuilder` struct and corresponding builder method for consistent span construction - Internal helper function `resolve_operation_id_from_env` in agent loop runner to reliably extract operation ID from environment variables **Changed:** - Refactored agent loop runner (`ares-llm/src/agent_loop/runner.rs`) to nest all agent task execution under a parent span containing `op.id` and `task.id` - Updated span creation in milestones, tool execution, and decision-making to include both operation and task identifiers - Modified span builder and helper functions (`ares-core/src/telemetry/spans/builder.rs`, `helpers.rs`) to accept and propagate the new identifiers as needed - Updated test cases in span module to verify presence of new attributes in spans - Updated GitHub Actions workflows to use the latest versions of `actions/upload-artifact` and `actions/setup-go` - Updated Semgrep workflow to use a new container image version for improved security and compatibility ---------
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Key Changes:
op.idandtask.idfields to all agent-related telemetry spans for improved correlation and traceabilityAdded:
op.idandtask.idspan attributes to all relevant agent, decision, tool call, discovery, and milestone telemetry spans for OpenTelemetry compatibility and enhanced query/filter capabilitiestask_idfield to theAgentSpanBuilderstruct and corresponding builder method for consistent span constructionresolve_operation_id_from_envin agent loop runner to reliably extract operation ID from environment variablesChanged:
Refactored agent loop runner (
ares-llm/src/agent_loop/runner.rs) to nest all agent task execution under a parent span containingop.idandtask.idUpdated span creation in milestones, tool execution, and decision-making to include both operation and task identifiers
Modified span builder and helper functions (
ares-core/src/telemetry/spans/builder.rs,helpers.rs) to accept and propagate the new identifiers as neededUpdated test cases in span module to verify presence of new attributes in spans
Updated GitHub Actions workflows to use the latest versions of
actions/upload-artifactandactions/setup-goUpdated Semgrep workflow to use a new container image version for improved security and compatibility