aKode fase 2c: eliminato il codice di invio dati (crate analytics, otel-trace-websocket, sentry, esportatori OTLP); /feedback salva solo in locale; chiavi legacy [analytics]/[otel] accettate e ignorate; test di analytics/OTLP/upload rimossi
Some checks failed
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled
Some checks failed
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled
This commit is contained in:
@@ -9,7 +9,6 @@ use std::io::Write as _;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
#[cfg(not(unix))]
|
||||
use tempfile::TempDir;
|
||||
use wiremock::Mock;
|
||||
@@ -176,7 +175,7 @@ async fn worktree_start_and_fork(backend: &str) -> anyhow::Result<()> {
|
||||
fs::create_dir(source.join(".codex"))?;
|
||||
fs::write(
|
||||
source.join(".codex/config.toml"),
|
||||
"model = \"destination-model\"\nanalytics.enabled = false\ncli_auth_credentials_store = \"file\"\n",
|
||||
"model = \"destination-model\"\ncli_auth_credentials_store = \"file\"\n",
|
||||
)?;
|
||||
git(&source, &["init", "--quiet"])?;
|
||||
git(&source, &["add", "."])?;
|
||||
@@ -190,7 +189,6 @@ async fn worktree_start_and_fork(backend: &str) -> anyhow::Result<()> {
|
||||
r#"
|
||||
cli_auth_credentials_store = "file"
|
||||
chatgpt_base_url = "{}/source/backend-api"
|
||||
analytics.enabled = false
|
||||
check_for_update_on_startup = false
|
||||
features.daemon_auto_start = {}
|
||||
features.mcp_oauth_refresh_coordination = true
|
||||
@@ -223,7 +221,7 @@ trust_level = "trusted"
|
||||
)?;
|
||||
fs::write(
|
||||
source.join(".codex/config.toml"),
|
||||
"model = \"source-model\"\nanalytics.enabled = true\n",
|
||||
"model = \"source-model\"\n",
|
||||
)?;
|
||||
app_test_support::write_chatgpt_auth(
|
||||
&home,
|
||||
@@ -253,11 +251,6 @@ trust_level = "trusted"
|
||||
env.insert("no_proxy".into(), "127.0.0.1,localhost".into());
|
||||
env.insert("TERM".into(), "xterm-256color".into());
|
||||
env.insert("TERM_PROGRAM".into(), "unrecognized-terminal".into());
|
||||
env.insert("OTEL_METRIC_EXPORT_INTERVAL".into(), "100".into());
|
||||
env.insert(
|
||||
"OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE".into(),
|
||||
"delta".into(),
|
||||
);
|
||||
for key in [
|
||||
"CODEX_EXEC_SERVER_URL",
|
||||
"CODEX_ACCESS_TOKEN",
|
||||
@@ -313,12 +306,11 @@ trust_level = "trusted"
|
||||
let mut owner = None;
|
||||
let mut previous: Vec<String> = Vec::new();
|
||||
let prompt = "describe checkout";
|
||||
for (fork, explicit_cd, analytics, auth_failure) in [
|
||||
(false, false, false, false),
|
||||
(true, false, false, false),
|
||||
(true, true, false, false),
|
||||
(false, false, true, false),
|
||||
(false, false, false, true),
|
||||
for (fork, explicit_cd, auth_failure) in [
|
||||
(false, false, false),
|
||||
(true, false, false),
|
||||
(true, true, false),
|
||||
(false, false, true),
|
||||
] {
|
||||
if auth_failure {
|
||||
fs::write(
|
||||
@@ -337,12 +329,8 @@ trust_level = "trusted"
|
||||
)?;
|
||||
fs::write(source.join(".codex/config.toml"), "")?;
|
||||
}
|
||||
let (metric_tx, mut metric_rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
Mock::given(wiremock::matchers::path("/metrics"))
|
||||
.respond_with(move |request: &wiremock::Request| {
|
||||
let _ = metric_tx.send(request.body.clone());
|
||||
ResponseTemplate::new(200).set_body_json(serde_json::json!({}))
|
||||
})
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({})))
|
||||
.mount(&server)
|
||||
.await;
|
||||
Mock::given(wiremock::matchers::method("GET"))
|
||||
@@ -410,18 +398,6 @@ trust_level = "trusted"
|
||||
if explicit_cd {
|
||||
args.extend(["--cd".into(), source.join(".codex").display().to_string()]);
|
||||
}
|
||||
if analytics {
|
||||
args.extend([
|
||||
"-c".into(),
|
||||
// An explicit collector is independent of built-in analytics consent.
|
||||
"analytics.enabled=false".into(),
|
||||
"-c".into(),
|
||||
format!(
|
||||
"otel.metrics_exporter={{otlp-http={{endpoint=\"{}/metrics\",protocol=\"json\"}}}}",
|
||||
server.uri()
|
||||
),
|
||||
]);
|
||||
}
|
||||
args.push(prompt.into());
|
||||
if previous.is_empty() {
|
||||
let mut untrusted_args = args.clone();
|
||||
@@ -536,7 +512,7 @@ trust_level = "trusted"
|
||||
} else {
|
||||
Ok(())
|
||||
};
|
||||
if backend == "daemon" && !analytics && matches!(observed, Ok(Ok(_))) {
|
||||
if backend == "daemon" && matches!(observed, Ok(Ok(_))) {
|
||||
session.writer_sender().send(b"/status\r".to_vec()).await?;
|
||||
tokio::time::timeout(Duration::from_secs(/*secs*/ 10), async {
|
||||
while !output.contains("Local background server") {
|
||||
@@ -555,46 +531,6 @@ trust_level = "trusted"
|
||||
.await
|
||||
.with_context(|| format!("daemon status timed out: {output}"))??;
|
||||
}
|
||||
if analytics {
|
||||
for reason in ["turn_start", "resize"] {
|
||||
let started = Instant::now();
|
||||
let wait = if reason == "resize" {
|
||||
session.resize(codex_utils_pty::TerminalSize {
|
||||
rows: 80,
|
||||
cols: 240,
|
||||
})?;
|
||||
Duration::from_secs(/*secs*/ 30)
|
||||
} else {
|
||||
Duration::from_secs(/*secs*/ 10)
|
||||
};
|
||||
tokio::time::timeout(wait, async {
|
||||
loop {
|
||||
tokio::select! {
|
||||
body = metric_rx.recv() => {
|
||||
let payload: Value = serde_json::from_slice(&body.context("metric body")?)?;
|
||||
let found = payload["resourceMetrics"].as_array().into_iter().flatten()
|
||||
.flat_map(|resource| resource["scopeMetrics"].as_array().into_iter().flatten())
|
||||
.flat_map(|scope| scope["metrics"].as_array().into_iter().flatten())
|
||||
.filter(|metric| metric["name"] == "codex.tui.terminal_size")
|
||||
.flat_map(|metric| metric["sum"]["dataPoints"].as_array().into_iter().flatten())
|
||||
.any(|point| point["attributes"].as_array().into_iter().flatten().any(|attribute|
|
||||
attribute["key"] == "observation_reason" && attribute["value"]["stringValue"] == reason));
|
||||
if found { return Ok::<_, anyhow::Error>(()); }
|
||||
}
|
||||
bytes = stdout.recv() => {
|
||||
let bytes = bytes.context("TUI exited before size observation")?;
|
||||
output.push_str(&String::from_utf8_lossy(&bytes));
|
||||
let replies = queries.feed(&bytes);
|
||||
if !replies.is_empty() { session.writer_sender().send(replies).await?; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}).await.with_context(|| format!("waiting for {reason} observation"))??;
|
||||
if reason == "resize" {
|
||||
assert!(started.elapsed() >= Duration::from_secs(/*secs*/ 15));
|
||||
}
|
||||
}
|
||||
}
|
||||
let startup_result = observed.as_ref().map(|result| result.as_ref().map(|_| ()));
|
||||
assert!(
|
||||
!output.contains("Under-development features enabled:"),
|
||||
@@ -656,110 +592,7 @@ trust_level = "trusted"
|
||||
.filter(|request| request.url.path() == "/metrics")
|
||||
.map(|request| serde_json::from_slice::<Value>(&request.body))
|
||||
.collect::<serde_json::Result<Vec<_>>>()?;
|
||||
if analytics {
|
||||
let exported = metrics
|
||||
.iter()
|
||||
.flat_map(|payload| payload["resourceMetrics"].as_array().into_iter().flatten())
|
||||
.flat_map(|resource| resource["scopeMetrics"].as_array().into_iter().flatten())
|
||||
.flat_map(|scope| scope["metrics"].as_array().into_iter().flatten())
|
||||
.collect::<Vec<_>>();
|
||||
if backend == "embedded" {
|
||||
let update = exported
|
||||
.iter()
|
||||
.find(|metric| metric["name"] == "codex.daemon.update")
|
||||
.context("handoff metric")?;
|
||||
let update_point = &update["sum"]["dataPoints"][0];
|
||||
assert_eq!(update_point["asInt"], 1);
|
||||
}
|
||||
let point = exported
|
||||
.iter()
|
||||
.filter(|metric| metric["name"] == "codex.tui.start")
|
||||
.flat_map(|metric| metric["sum"]["dataPoints"].as_array().into_iter().flatten())
|
||||
.next()
|
||||
.context("codex.tui.start data point")?;
|
||||
assert_eq!(point["asInt"], 1);
|
||||
let tags = point["attributes"]
|
||||
.as_array()
|
||||
.context("codex.tui.start attributes")?
|
||||
.iter()
|
||||
.map(|attribute| {
|
||||
Ok((
|
||||
attribute["key"].as_str().context("metric tag key")?,
|
||||
attribute["value"]["stringValue"]
|
||||
.as_str()
|
||||
.context("metric tag value")?,
|
||||
))
|
||||
})
|
||||
.collect::<anyhow::Result<HashMap<_, _>>>()?;
|
||||
let mut expected_tags = HashMap::from([
|
||||
("app_server_mode", "in_process"),
|
||||
("terminal_name", "unknown"),
|
||||
("terminal_columns", "120-239"),
|
||||
("terminal_rows", "40-79"),
|
||||
("multiplexer", "none"),
|
||||
("daemon_selection_reason", "incompatible_option"),
|
||||
(
|
||||
"daemon_auto_start",
|
||||
if backend == "daemon" {
|
||||
"enabled"
|
||||
} else {
|
||||
"disabled"
|
||||
},
|
||||
),
|
||||
("auto_update", "enabled"),
|
||||
("auto_update_setting", "default"),
|
||||
("update_interval_setting", "default"),
|
||||
("shutdown_grace_setting", "default"),
|
||||
]);
|
||||
#[cfg(windows)]
|
||||
if codex_app_server_daemon::is_elevated()? {
|
||||
expected_tags.insert("daemon_selection_reason", "elevated_windows");
|
||||
}
|
||||
if backend == "daemon" {
|
||||
expected_tags.extend([
|
||||
("auto_update", "disabled"),
|
||||
("auto_update_setting", "configured"),
|
||||
("shutdown_grace_setting", "configured"),
|
||||
]);
|
||||
}
|
||||
assert_eq!(tags, expected_tags);
|
||||
let observations = exported
|
||||
.iter()
|
||||
.filter(|metric| metric["name"] == "codex.tui.terminal_size")
|
||||
.flat_map(|metric| metric["sum"]["dataPoints"].as_array().into_iter().flatten())
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(observations.len(), 2);
|
||||
for observation in observations {
|
||||
assert_eq!(observation["asInt"], 1);
|
||||
let observation_tags = observation["attributes"]
|
||||
.as_array()
|
||||
.context("observation attributes")?
|
||||
.iter()
|
||||
.map(|attribute| {
|
||||
Ok((
|
||||
attribute["key"].as_str().context("observation key")?,
|
||||
attribute["value"]["stringValue"]
|
||||
.as_str()
|
||||
.context("observation value")?,
|
||||
))
|
||||
})
|
||||
.collect::<anyhow::Result<HashMap<_, _>>>()?;
|
||||
let reason = observation_tags["observation_reason"];
|
||||
let mut expected = expected_tags.clone();
|
||||
expected.insert("observation_reason", reason);
|
||||
match reason {
|
||||
"turn_start" => {}
|
||||
"resize" => {
|
||||
expected.insert("terminal_columns", "240-479");
|
||||
expected.insert("terminal_rows", "80-119");
|
||||
}
|
||||
other => anyhow::bail!("unexpected observation: {other}"),
|
||||
}
|
||||
assert_eq!(observation_tags, expected);
|
||||
}
|
||||
} else {
|
||||
assert!(metrics.is_empty(), "metrics exporter disabled");
|
||||
}
|
||||
assert!(metrics.is_empty(), "no telemetry may be exported");
|
||||
let (body, checkout, metadata) = observed
|
||||
.with_context(|| {
|
||||
format!(
|
||||
|
||||
Reference in New Issue
Block a user