| 13 | } |
| 14 | |
| 15 | fn record_tool_result_metadata(tool_name: &str, args: &serde_json::Value, exit_code: i32) { |
| 16 | let span = tracing::Span::current(); |
| 17 | span.record(crate::telemetry::ATTR_TOOL_NAME, tool_name); |
| 18 | span.record(crate::telemetry::ATTR_TOOL_EXIT_CODE, exit_code as i64); |
| 19 | span.record(crate::telemetry::ATTR_TOOL_SUCCESS, exit_code == 0); |
| 20 | |
| 21 | tracing::debug!( |
| 22 | a3s.tool.name = tool_name, |
| 23 | a3s.tool.exit_code = exit_code, |
| 24 | a3s.tool.success = exit_code == 0, |
| 25 | a3s.tool.args_bytes = serde_json::to_string(args) |
| 26 | .map(|s| s.len()) |
| 27 | .unwrap_or_default(), |
| 28 | "Tool execution result recorded" |
| 29 | ); |
| 30 | } |
| 31 | |
| 32 | #[cfg(test)] |
| 33 | mod tests { |