Unverified Commit 87e7b083 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Improve "make root node" trace attributes (#92941)

### What?

Improve the trace span attributes for "make root node" operations in the
turbo-tasks backend. Instead of recording only the raw `task_id`, the
spans now include a human-readable task description (type name + task
ID) via `debug_get_task_description`.

### Why?

When profiling or debugging with tracing tools, raw task IDs are opaque
and require additional lookups to understand which task is being
processed. Including a human-readable task description (e.g. `TaskId(42)
MyFunction(args...)`) makes traces immediately actionable.

Two spans were affected:
- `"make root node for strongly consistent read"` in `backend/mod.rs`
- `"make root node for removing collectible"` in
`backend/operation/update_collectible.rs`

### How?

- Added `debug_get_task_description` method to the `ExecuteContext`
trait in `operation/mod.rs`
- Implemented it on `ExecuteContextImpl` by delegating to the existing
`backend.debug_get_task_description` method (already used in other
tracing spans)
- Replaced `%task_id` (which formats only the ID) with `task =
self.debug_get_task_description(task_id)` / `task =
ctx.debug_get_task_description(task_id)` in both span definitions

<!-- NEXT_JS_LLM_PR -->
parent 1aeb6b1c
...@@ -555,7 +555,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -555,7 +555,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
{ {
let _span = tracing::trace_span!( let _span = tracing::trace_span!(
"make root node for strongly consistent read", "make root node for strongly consistent read",
%task_id task = self.debug_get_task_description(task_id)
) )
.entered(); .entered();
AggregationUpdateQueue::run( AggregationUpdateQueue::run(
......
...@@ -112,6 +112,7 @@ pub trait ExecuteContext<'e>: Sized { ...@@ -112,6 +112,7 @@ pub trait ExecuteContext<'e>: Sized {
this: Option<RawVc>, this: Option<RawVc>,
arg: &dyn DynTaskInputs, arg: &dyn DynTaskInputs,
) -> Option<(TaskId, Arc<CachedTaskType>)>; ) -> Option<(TaskId, Arc<CachedTaskType>)>;
fn debug_get_task_description(&self, task_id: TaskId) -> String;
} }
pub trait ChildExecuteContext<'e>: Send + Sized { pub trait ChildExecuteContext<'e>: Send + Sized {
...@@ -1007,6 +1008,10 @@ impl<'e, B: BackingStorage> ExecuteContext<'e> for ExecuteContextImpl<'e, B> { ...@@ -1007,6 +1008,10 @@ impl<'e, B: BackingStorage> ExecuteContext<'e> for ExecuteContextImpl<'e, B> {
} }
None None
} }
fn debug_get_task_description(&self, task_id: TaskId) -> String {
self.backend.debug_get_task_description(task_id)
}
} }
struct ChildExecuteContextImpl<'e, B: BackingStorage> { struct ChildExecuteContextImpl<'e, B: BackingStorage> {
......
...@@ -36,7 +36,7 @@ impl UpdateCollectibleOperation { ...@@ -36,7 +36,7 @@ impl UpdateCollectibleOperation {
{ {
let _span = tracing::trace_span!( let _span = tracing::trace_span!(
"make root node for removing collectible", "make root node for removing collectible",
%task_id task = ctx.debug_get_task_description(task_id)
) )
.entered(); .entered();
AggregationUpdateQueue::run( AggregationUpdateQueue::run(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment