mirror of
https://github.com/openai/codex.git
synced 2026-04-24 22:54:54 +00:00
feat: reduce span exposition (#10171)
This only avoids the creation of duplicates spans
This commit is contained in:
@@ -51,7 +51,12 @@ pub(crate) async fn handle_output_item_done(
|
|||||||
// The model emitted a tool call; log it, persist the item immediately, and queue the tool execution.
|
// The model emitted a tool call; log it, persist the item immediately, and queue the tool execution.
|
||||||
Ok(Some(call)) => {
|
Ok(Some(call)) => {
|
||||||
let payload_preview = call.payload.log_payload().into_owned();
|
let payload_preview = call.payload.log_payload().into_owned();
|
||||||
tracing::info!("ToolCall: {} {}", call.tool_name, payload_preview);
|
tracing::info!(
|
||||||
|
thread_id = %ctx.sess.conversation_id,
|
||||||
|
"ToolCall: {} {}",
|
||||||
|
call.tool_name,
|
||||||
|
payload_preview
|
||||||
|
);
|
||||||
|
|
||||||
ctx.sess
|
ctx.sess
|
||||||
.record_conversation_items(&ctx.turn_context, std::slice::from_ref(&item))
|
.record_conversation_items(&ctx.turn_context, std::slice::from_ref(&item))
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use tokio::sync::Notify;
|
|||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
use tokio_util::task::AbortOnDropHandle;
|
use tokio_util::task::AbortOnDropHandle;
|
||||||
use tracing::Instrument;
|
use tracing::Instrument;
|
||||||
use tracing::info_span;
|
use tracing::Span;
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
|
|
||||||
@@ -132,8 +132,7 @@ impl Session {
|
|||||||
let ctx = Arc::clone(&turn_context);
|
let ctx = Arc::clone(&turn_context);
|
||||||
let task_for_run = Arc::clone(&task);
|
let task_for_run = Arc::clone(&task);
|
||||||
let task_cancellation_token = cancellation_token.child_token();
|
let task_cancellation_token = cancellation_token.child_token();
|
||||||
let thread_id = self.conversation_id;
|
let session_span = Span::current();
|
||||||
let session_span = info_span!("session_task", thread_id = %thread_id);
|
|
||||||
tokio::spawn(
|
tokio::spawn(
|
||||||
async move {
|
async move {
|
||||||
let ctx_for_finish = Arc::clone(&ctx);
|
let ctx_for_finish = Arc::clone(&ctx);
|
||||||
|
|||||||
@@ -221,20 +221,16 @@ fn to_log_query(
|
|||||||
fn format_row(row: &LogRow) -> String {
|
fn format_row(row: &LogRow) -> String {
|
||||||
let timestamp = format_timestamp(row.ts, row.ts_nanos);
|
let timestamp = format_timestamp(row.ts, row.ts_nanos);
|
||||||
let level = row.level.as_str();
|
let level = row.level.as_str();
|
||||||
let location = match (&row.file, row.line) {
|
let target = row.target.as_str();
|
||||||
(Some(file), Some(line)) => format!("{file}:{line}"),
|
|
||||||
(Some(file), None) => file.clone(),
|
|
||||||
_ => "-".to_string(),
|
|
||||||
};
|
|
||||||
let message = row.message.as_deref().unwrap_or("");
|
let message = row.message.as_deref().unwrap_or("");
|
||||||
let level_colored = color_level(level);
|
let level_colored = color_level(level);
|
||||||
let timestamp_colored = timestamp.dimmed().to_string();
|
let timestamp_colored = timestamp.dimmed().to_string();
|
||||||
let thread_id = row.thread_id.as_deref().unwrap_or("-");
|
let thread_id = row.thread_id.as_deref().unwrap_or("-");
|
||||||
let thread_id_colored = thread_id.yellow().to_string();
|
let thread_id_colored = thread_id.blue().dimmed().to_string();
|
||||||
let location_colored = location.dimmed().to_string();
|
let target_colored = target.dimmed().to_string();
|
||||||
let message_colored = message.bold().to_string();
|
let message_colored = message.bold().to_string();
|
||||||
format!(
|
format!(
|
||||||
"{timestamp_colored} {level_colored} [{thread_id_colored}] {location_colored} - {message_colored}"
|
"{timestamp_colored} {level_colored} [{thread_id_colored}] {target_colored} - {message_colored}"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ pub struct LogRow {
|
|||||||
pub ts: i64,
|
pub ts: i64,
|
||||||
pub ts_nanos: i64,
|
pub ts_nanos: i64,
|
||||||
pub level: String,
|
pub level: String,
|
||||||
|
pub target: String,
|
||||||
pub message: Option<String>,
|
pub message: Option<String>,
|
||||||
pub thread_id: Option<String>,
|
pub thread_id: Option<String>,
|
||||||
pub file: Option<String>,
|
pub file: Option<String>,
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ FROM threads
|
|||||||
/// Query logs with optional filters.
|
/// Query logs with optional filters.
|
||||||
pub async fn query_logs(&self, query: &LogQuery) -> anyhow::Result<Vec<LogRow>> {
|
pub async fn query_logs(&self, query: &LogQuery) -> anyhow::Result<Vec<LogRow>> {
|
||||||
let mut builder = QueryBuilder::<Sqlite>::new(
|
let mut builder = QueryBuilder::<Sqlite>::new(
|
||||||
"SELECT id, ts, ts_nanos, level, message, thread_id, file, line FROM logs WHERE 1 = 1",
|
"SELECT id, ts, ts_nanos, level, target, message, thread_id, file, line FROM logs WHERE 1 = 1",
|
||||||
);
|
);
|
||||||
push_log_filters(&mut builder, query);
|
push_log_filters(&mut builder, query);
|
||||||
if query.descending {
|
if query.descending {
|
||||||
|
|||||||
@@ -306,7 +306,10 @@ pub async fn run_main(
|
|||||||
// grep for a specific module/target while troubleshooting.
|
// grep for a specific module/target while troubleshooting.
|
||||||
.with_target(true)
|
.with_target(true)
|
||||||
.with_ansi(false)
|
.with_ansi(false)
|
||||||
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::FULL)
|
.with_span_events(
|
||||||
|
tracing_subscriber::fmt::format::FmtSpan::NEW
|
||||||
|
| tracing_subscriber::fmt::format::FmtSpan::CLOSE,
|
||||||
|
)
|
||||||
.with_filter(env_filter());
|
.with_filter(env_filter());
|
||||||
|
|
||||||
let feedback = codex_feedback::CodexFeedback::new();
|
let feedback = codex_feedback::CodexFeedback::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user