mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
add sandbox policy and sandbox name to codex.tool.call metrics (#10711)
This will give visibility into the comparative success rate of the Windows sandbox implementations compared to other platforms.
This commit is contained in:
@@ -566,11 +566,12 @@ impl OtelManager {
|
||||
);
|
||||
}
|
||||
|
||||
pub async fn log_tool_result<F, Fut, E>(
|
||||
pub async fn log_tool_result_with_tags<F, Fut, E>(
|
||||
&self,
|
||||
tool_name: &str,
|
||||
call_id: &str,
|
||||
arguments: &str,
|
||||
extra_tags: &[(&str, &str)],
|
||||
f: F,
|
||||
) -> Result<(String, bool), E>
|
||||
where
|
||||
@@ -587,13 +588,14 @@ impl OtelManager {
|
||||
Err(error) => (Cow::Owned(error.to_string()), false),
|
||||
};
|
||||
|
||||
self.tool_result(
|
||||
self.tool_result_with_tags(
|
||||
tool_name,
|
||||
call_id,
|
||||
arguments,
|
||||
duration,
|
||||
success,
|
||||
output.as_ref(),
|
||||
extra_tags,
|
||||
);
|
||||
|
||||
result
|
||||
@@ -619,7 +621,8 @@ impl OtelManager {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn tool_result(
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn tool_result_with_tags(
|
||||
&self,
|
||||
tool_name: &str,
|
||||
call_id: &str,
|
||||
@@ -627,18 +630,15 @@ impl OtelManager {
|
||||
duration: Duration,
|
||||
success: bool,
|
||||
output: &str,
|
||||
extra_tags: &[(&str, &str)],
|
||||
) {
|
||||
let success_str = if success { "true" } else { "false" };
|
||||
self.counter(
|
||||
TOOL_CALL_COUNT_METRIC,
|
||||
1,
|
||||
&[("tool", tool_name), ("success", success_str)],
|
||||
);
|
||||
self.record_duration(
|
||||
TOOL_CALL_DURATION_METRIC,
|
||||
duration,
|
||||
&[("tool", tool_name), ("success", success_str)],
|
||||
);
|
||||
let mut tags = Vec::with_capacity(2 + extra_tags.len());
|
||||
tags.push(("tool", tool_name));
|
||||
tags.push(("success", success_str));
|
||||
tags.extend_from_slice(extra_tags);
|
||||
self.counter(TOOL_CALL_COUNT_METRIC, 1, &tags);
|
||||
self.record_duration(TOOL_CALL_DURATION_METRIC, duration, &tags);
|
||||
tracing::event!(
|
||||
tracing::Level::INFO,
|
||||
event.name = "codex.tool_result",
|
||||
|
||||
Reference in New Issue
Block a user