mirror of
https://github.com/openai/codex.git
synced 2026-10-18 17:18:52 +00:00
Record web search result payload sizes (#33851)
## What changed Record the serialized size of structured web search results in the `codex.web_search.results.payload_bytes` histogram when telemetry is available. GitOrigin-RevId: 6e87e21d3ae7de03079ecaf6cd08f9770dffc436
This commit is contained in:
Generated
+1
@@ -4454,6 +4454,7 @@ dependencies = [
|
||||
"codex-login",
|
||||
"codex-model-provider",
|
||||
"codex-model-provider-info",
|
||||
"codex-otel",
|
||||
"codex-protocol",
|
||||
"codex-tools",
|
||||
"http 1.4.0",
|
||||
|
||||
@@ -20,6 +20,7 @@ codex-extension-items = { workspace = true }
|
||||
codex-login = { workspace = true }
|
||||
codex-model-provider = { workspace = true }
|
||||
codex-model-provider-info = { workspace = true }
|
||||
codex-otel = { workspace = true }
|
||||
codex-protocol = { workspace = true }
|
||||
codex-tools = { workspace = true }
|
||||
http = { workspace = true }
|
||||
|
||||
@@ -40,6 +40,7 @@ use crate::schema::commands_schema;
|
||||
pub(crate) const WEB_NAMESPACE: &str = "web";
|
||||
pub(crate) const RUN_TOOL_NAME: &str = "run";
|
||||
const WEB_RUN_DESCRIPTION: &str = include_str!("../web_run_description.md");
|
||||
const RESULTS_PAYLOAD_BYTES_METRIC: &str = "codex.web_search.results.payload_bytes";
|
||||
|
||||
pub(crate) struct WebSearchTool {
|
||||
pub(crate) session_id: String,
|
||||
@@ -140,6 +141,13 @@ impl WebSearchTool {
|
||||
.map_err(|err| FunctionCallError::Fatal(err.to_string()))?;
|
||||
let output = response.output;
|
||||
let results = response.results;
|
||||
if let Some(results) = results.as_ref()
|
||||
&& let Some(metrics) = codex_otel::global()
|
||||
&& let Ok(payload) = serde_json::to_vec(results)
|
||||
{
|
||||
let payload_bytes = i64::try_from(payload.len()).unwrap_or(i64::MAX);
|
||||
let _ = metrics.histogram(RESULTS_PAYLOAD_BYTES_METRIC, payload_bytes, &[]);
|
||||
}
|
||||
let legacy_action = match &command_action {
|
||||
WebSearchAction::Search { query, queries } => CoreWebSearchAction::Search {
|
||||
query: query.clone(),
|
||||
|
||||
Reference in New Issue
Block a user