Add turn, tool, and skill attribution to traces (#56524)

## What changed

- Emit `codex.turn_profile` events with finalized sampling request and retry counts when turns complete or abort, and preserve the caller's tracing span for detached extension interrupts.
- Add conversation and turn identifiers to turn and tool dispatch spans, identify tool sources, and include dispatch-to-result-ready duration on tool completion events.
- Emit `codex.skill_read.source_selected` before cache or provider access, recording the selected cloud or executor source, skill and plugin identity, resource kind, and continuation status.

## Testing

Add regression coverage for trace correlation, tool completion timing, turn profile counters on completion and interruption, detached interrupt span propagation, and skill source attribution including cached cloud reads.

GitOrigin-RevId: db78aa270bbcb8dc9e4558d202c109ad54141811
This commit is contained in:
bkotsopoulos
2026-10-23 16:55:32 +00:00
committed by copyberry
parent 3985001067
commit b82d542aef
13 changed files with 363 additions and 15 deletions
+5
View File
@@ -345,6 +345,7 @@ fn submit_nested_tool(
impl std::future::Future<Output = Result<JsonValue, FunctionCallError>> + Send + 'static,
FunctionCallError,
> {
let dispatch_started = std::time::Instant::now();
let CodeModeNestedToolCall {
cell_id,
runtime_tool_call_id,
@@ -361,6 +362,9 @@ fn submit_nested_tool(
target: "codex_otel.trace_safe",
tracing::Level::INFO,
event.name = "codex.code_mode.nested_tool_dispatched",
tool_name = tool_name.name.as_str(),
tool_namespace = call_trace::namespace(&tool_name),
tool_source = "code_mode",
conversation.id = %thread_id,
turn_id = turn_id.as_str(),
cell.id = telemetry::trace_id(cell_id.as_str()),
@@ -381,6 +385,7 @@ fn submit_nested_tool(
&tool_name,
&call_id,
call_trace::Source::CodeMode,
dispatch_started.elapsed(),
);
return Err(FunctionCallError::RespondToModel(error));
}