feat(adk): support task_id on span creation#329
Merged
declan-scale merged 1 commit intonextfrom Apr 21, 2026
Merged
Conversation
Merged
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.
Summary
task_idthrough ADK span creation (TracingModule.start_span/spancontext manager →TracingService→StartSpanParamsactivity →Trace/AsyncTrace.start_span), so spans can be associated with the task that produced themend_spanintentionally unchanged — it already forwards the existingSpanobject which carriestask_idfrom creation, matching how other fields (name, parent_id, input) are handledtask_idis set on theSpanand plumbed through correctly, and that it's preserved throughend_spanTest plan
rye run pytest tests/lib/adk/test_tracing_module.py tests/lib/adk/test_tracing_activities.py tests/lib/adk/test_tracing_service.py tests/lib/core/tracing/test_trace_task_id.py— 17 passedrye run pytest tests/lib/core/tracing/ tests/lib/adk/— no regressions (86 passed, 2 pre-existing skips)rye run ruff format+rye run ruff checkon touched files — clean🤖 Generated with Claude Code
Greptile Summary
This PR threads an optional
task_idparameter through the full ADK span creation stack — fromTracingModule.start_span/spancontext manager down throughStartSpanParams,TracingActivities,TracingService, and into bothTraceandAsyncTrace.start_span— so spans can be associated with the task that produced them.end_spanis intentionally left unchanged since theSpanobject already carriestask_idfrom creation. Coverage is thorough with 17 new tests across all four layers.Confidence Score: 5/5
Safe to merge — additive, backward-compatible change with comprehensive test coverage at every layer.
All changed files introduce only an optional parameter with a
Nonedefault, preserving backward compatibility throughout. TheSpanmodel already hadtask_id. Tests cover all four layers (core trace, service, activity, module). The one P2 finding (AgentexLangGraphTracingHandlernot yet forwardingtask_id) is a gap in coverage, not a regression.No files require special attention. Optionally consider updating
_langgraph_tracing.pyin a follow-up to propagatetask_idthrough LLM/tool child spans.Important Files Changed
task_idparam to bothstart_spanandspancontext manager, threading it through toStartSpanParamsand directTracingServicecalls. Clean, backward-compatible addition.task_idparameter and forwards it totrace.start_span. Minimal, correct change.task_idtoTrace.start_span,AsyncTrace.start_span, and bothspancontext managers; stored on theSpanobject at creation.task_idforwarding at the module level forstart_span,end_span, and the context manager, including the no-op case.task_idis plumbed throughStartSpanParamsand preserved acrossend_span.task_idis forwarded totrace.start_spanand thatend_spancorrectly passes through the span object.TraceandAsyncTracesettask_idon theSpanand thatend_spanpreserves it.Sequence Diagram
sequenceDiagram participant Caller participant TracingModule participant StartSpanParams participant TracingActivities participant TracingService participant AsyncTrace participant Span Caller->>TracingModule: start_span(trace_id, name, task_id) alt in Temporal workflow TracingModule->>StartSpanParams: StartSpanParams(task_id=task_id) TracingModule->>TracingActivities: execute_activity(START_SPAN, params) TracingActivities->>TracingService: start_span(..., task_id=params.task_id) else direct call TracingModule->>TracingService: start_span(..., task_id=task_id) end TracingService->>AsyncTrace: trace.start_span(..., task_id=task_id) AsyncTrace->>Span: Span(task_id=task_id, ...) Span-->>Caller: span (with task_id set)Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "Add task_id to span creation" | Re-trigger Greptile