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:
@@ -43,7 +43,6 @@ use crate::permissions_toml::PermissionProfileToml;
|
||||
use crate::types::AuthCredentialsStoreMode;
|
||||
use crate::types::FeedbackConfigToml;
|
||||
use crate::types::OtelConfigToml;
|
||||
use crate::types::OtelExporterKind;
|
||||
use crate::types::WindowsSandboxModeToml;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -1002,7 +1001,8 @@ impl FeatureRequirementsToml {
|
||||
#[derive(Deserialize, Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub struct AppToolRequirementToml {
|
||||
pub approval_mode: Option<AppToolApproval>,
|
||||
/// Opt-in analytics extraction for this exact tool, not a tool argument.
|
||||
/// Deprecated and ignored: tool-result metadata is never captured. Accepted only so
|
||||
/// existing managed requirements keep parsing.
|
||||
/// The highest-priority rule wins as a whole, including unsupported formats.
|
||||
pub analytics_result_source: Option<AppToolResultSourceRequirementToml>,
|
||||
}
|
||||
@@ -1186,24 +1186,84 @@ pub struct ConfigRequirementsToml {
|
||||
pub guardian_extra_policy: Option<String>,
|
||||
}
|
||||
|
||||
/// OTEL settings that may be managed through `requirements.toml`.
|
||||
/// Local logging settings that may be managed through `requirements.toml`.
|
||||
///
|
||||
/// Tool-result limits are optional here because `config.toml` defaults them,
|
||||
/// while requirements must distinguish unset from managed-to-default.
|
||||
///
|
||||
/// aKode never exports telemetry: the former exporter keys are still accepted
|
||||
/// so existing managed requirements keep parsing, but their values are ignored.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct OtelRequirementsToml {
|
||||
pub tool_result: Option<ToolResultLogConfig>,
|
||||
pub log_sse_deltas: Option<bool>,
|
||||
pub log_user_prompt: Option<bool>,
|
||||
pub log_agent_responses: Option<bool>,
|
||||
pub log_guardian_assessments: Option<bool>,
|
||||
pub environment: Option<String>,
|
||||
pub exporter: Option<OtelExporterKind>,
|
||||
pub trace_exporter: Option<OtelExporterKind>,
|
||||
pub metrics_exporter: Option<OtelExporterKind>,
|
||||
pub span_attributes: Option<HashMap<String, String>>,
|
||||
pub tracestate: Option<BTreeMap<String, BTreeMap<String, String>>>,
|
||||
/// Deprecated and ignored.
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing,
|
||||
deserialize_with = "discard_legacy_otel_key"
|
||||
)]
|
||||
pub log_agent_responses: Option<toml::Value>,
|
||||
/// Deprecated and ignored.
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing,
|
||||
deserialize_with = "discard_legacy_otel_key"
|
||||
)]
|
||||
pub log_guardian_assessments: Option<toml::Value>,
|
||||
/// Deprecated and ignored.
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing,
|
||||
deserialize_with = "discard_legacy_otel_key"
|
||||
)]
|
||||
pub environment: Option<toml::Value>,
|
||||
/// Deprecated and ignored: telemetry exporters were removed.
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing,
|
||||
deserialize_with = "discard_legacy_otel_key"
|
||||
)]
|
||||
pub exporter: Option<toml::Value>,
|
||||
/// Deprecated and ignored: telemetry exporters were removed.
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing,
|
||||
deserialize_with = "discard_legacy_otel_key"
|
||||
)]
|
||||
pub trace_exporter: Option<toml::Value>,
|
||||
/// Deprecated and ignored: telemetry exporters were removed.
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing,
|
||||
deserialize_with = "discard_legacy_otel_key"
|
||||
)]
|
||||
pub metrics_exporter: Option<toml::Value>,
|
||||
/// Deprecated and ignored.
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing,
|
||||
deserialize_with = "discard_legacy_otel_key"
|
||||
)]
|
||||
pub span_attributes: Option<toml::Value>,
|
||||
/// Deprecated and ignored.
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing,
|
||||
deserialize_with = "discard_legacy_otel_key"
|
||||
)]
|
||||
pub tracestate: Option<toml::Value>,
|
||||
}
|
||||
|
||||
/// Accepts a deprecated `[otel]` requirement key and discards its value.
|
||||
fn discard_legacy_otel_key<'de, D>(deserializer: D) -> Result<Option<toml::Value>, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
serde::de::IgnoredAny::deserialize(deserializer)?;
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
impl OtelRequirementsToml {
|
||||
@@ -1211,23 +1271,6 @@ impl OtelRequirementsToml {
|
||||
self.tool_result.is_none()
|
||||
&& self.log_sse_deltas.is_none()
|
||||
&& self.log_user_prompt.is_none()
|
||||
&& self.log_agent_responses.is_none()
|
||||
&& self.log_guardian_assessments.is_none()
|
||||
&& self.environment.is_none()
|
||||
&& self.exporter.is_none()
|
||||
&& self.trace_exporter.is_none()
|
||||
&& self.metrics_exporter.is_none()
|
||||
&& !self.has_metadata()
|
||||
}
|
||||
|
||||
fn has_metadata(&self) -> bool {
|
||||
self.span_attributes
|
||||
.as_ref()
|
||||
.is_some_and(|fields| !fields.is_empty())
|
||||
|| self
|
||||
.tracestate
|
||||
.as_ref()
|
||||
.is_some_and(|members| members.values().any(|fields| !fields.is_empty()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1882,7 +1925,7 @@ impl ConfigRequirementsToml {
|
||||
return Some("model_providers");
|
||||
}
|
||||
let otel = self.otel.as_ref();
|
||||
let managed_fields: [(bool, &[&str], &'static str); 18] = [
|
||||
let managed_fields: [(bool, &[&str], &'static str); 12] = [
|
||||
(
|
||||
self.model_provider.is_some(),
|
||||
&["model_provider"],
|
||||
@@ -1938,36 +1981,6 @@ impl ConfigRequirementsToml {
|
||||
&["otel", "log_sse_deltas"],
|
||||
"otel.log_sse_deltas",
|
||||
),
|
||||
(
|
||||
otel.is_some_and(|otel| otel.log_agent_responses.is_some()),
|
||||
&["otel", "log_agent_responses"],
|
||||
"otel.log_agent_responses",
|
||||
),
|
||||
(
|
||||
otel.is_some_and(|otel| otel.log_guardian_assessments.is_some()),
|
||||
&["otel", "log_guardian_assessments"],
|
||||
"otel.log_guardian_assessments",
|
||||
),
|
||||
(
|
||||
otel.is_some_and(|otel| otel.environment.is_some()),
|
||||
&["otel", "environment"],
|
||||
"otel.environment",
|
||||
),
|
||||
(
|
||||
otel.is_some_and(|otel| otel.exporter.is_some()),
|
||||
&["otel", "exporter"],
|
||||
"otel.exporter",
|
||||
),
|
||||
(
|
||||
otel.is_some_and(|otel| otel.trace_exporter.is_some()),
|
||||
&["otel", "trace_exporter"],
|
||||
"otel.trace_exporter",
|
||||
),
|
||||
(
|
||||
otel.is_some_and(|otel| otel.metrics_exporter.is_some()),
|
||||
&["otel", "metrics_exporter"],
|
||||
"otel.metrics_exporter",
|
||||
),
|
||||
];
|
||||
|
||||
managed_fields
|
||||
@@ -1975,11 +1988,6 @@ impl ConfigRequirementsToml {
|
||||
.find_map(|(is_managed, managed_path, field)| {
|
||||
(is_managed && config_paths_overlap(segments, managed_path)).then_some(field)
|
||||
})
|
||||
.or_else(|| {
|
||||
otel.and_then(|otel| {
|
||||
exact_otel_metadata_requirement_for_config_path(otel, segments)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1995,15 +2003,6 @@ macro_rules! otel_merge_functions {
|
||||
requirements.get_or_insert_default().$field = Some(value.clone());
|
||||
contributed = true;
|
||||
})+
|
||||
if higher_priority.has_metadata() {
|
||||
let target = requirements.get_or_insert_default();
|
||||
merge_otel_metadata(
|
||||
&mut target.span_attributes,
|
||||
&mut target.tracestate,
|
||||
higher_priority,
|
||||
);
|
||||
contributed = true;
|
||||
}
|
||||
contributed
|
||||
}
|
||||
|
||||
@@ -2017,91 +2016,12 @@ macro_rules! otel_merge_functions {
|
||||
conflict |= config.$field.as_ref().is_some_and(|current| current != value);
|
||||
config.$field = Some(value.clone());
|
||||
})+
|
||||
conflict |= merge_otel_metadata(
|
||||
&mut config.span_attributes,
|
||||
&mut config.tracestate,
|
||||
requirements,
|
||||
);
|
||||
conflict
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
otel_merge_functions!(
|
||||
tool_result,
|
||||
log_sse_deltas,
|
||||
log_user_prompt,
|
||||
log_agent_responses,
|
||||
log_guardian_assessments,
|
||||
environment,
|
||||
exporter,
|
||||
trace_exporter,
|
||||
metrics_exporter,
|
||||
);
|
||||
|
||||
fn merge_otel_metadata(
|
||||
span_attributes: &mut Option<HashMap<String, String>>,
|
||||
tracestate: &mut Option<BTreeMap<String, BTreeMap<String, String>>>,
|
||||
requirements: &OtelRequirementsToml,
|
||||
) -> bool {
|
||||
let mut conflict = false;
|
||||
if let Some(attributes) = &requirements.span_attributes
|
||||
&& !attributes.is_empty()
|
||||
{
|
||||
let configured = span_attributes.get_or_insert_default();
|
||||
for (key, value) in attributes {
|
||||
conflict |= configured
|
||||
.insert(key.clone(), value.clone())
|
||||
.is_some_and(|configured| configured != *value);
|
||||
}
|
||||
}
|
||||
if let Some(members) = &requirements.tracestate {
|
||||
for (member, fields) in members.iter().filter(|(_, fields)| !fields.is_empty()) {
|
||||
let configured = tracestate
|
||||
.get_or_insert_default()
|
||||
.entry(member.clone())
|
||||
.or_default();
|
||||
for (key, value) in fields {
|
||||
conflict |= configured
|
||||
.insert(key.clone(), value.clone())
|
||||
.is_some_and(|configured| configured != *value);
|
||||
}
|
||||
}
|
||||
}
|
||||
conflict
|
||||
}
|
||||
|
||||
fn exact_otel_metadata_requirement_for_config_path(
|
||||
requirements: &OtelRequirementsToml,
|
||||
segments: &[String],
|
||||
) -> Option<&'static str> {
|
||||
if requirements
|
||||
.span_attributes
|
||||
.as_ref()
|
||||
.is_some_and(|attributes| {
|
||||
attributes.keys().any(|key| {
|
||||
config_paths_overlap(segments, &["otel", "span_attributes", key.as_str()])
|
||||
})
|
||||
})
|
||||
{
|
||||
return Some("otel.span_attributes");
|
||||
}
|
||||
|
||||
requirements
|
||||
.tracestate
|
||||
.as_ref()
|
||||
.is_some_and(|members| {
|
||||
members.iter().any(|(member, fields)| {
|
||||
fields.keys().any(|field| {
|
||||
config_paths_overlap(
|
||||
segments,
|
||||
&["otel", "tracestate", member.as_str(), field.as_str()],
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
.then_some("otel.tracestate")
|
||||
}
|
||||
otel_merge_functions!(tool_result, log_sse_deltas, log_user_prompt);
|
||||
|
||||
fn config_paths_overlap(segments: &[String], managed_path: &[&str]) -> bool {
|
||||
segments
|
||||
@@ -2683,23 +2603,17 @@ mod tests {
|
||||
#[test_case::test_case(&["otel", "tool_result", "max_bytes"], Some("otel.tool_result"); "tool_result_max_bytes")]
|
||||
#[test_case::test_case(&["otel", "log_user_prompt"], Some("otel.log_user_prompt"); "log_user_prompt")]
|
||||
#[test_case::test_case(&["otel", "log_sse_deltas"], Some("otel.log_sse_deltas"); "log_sse_deltas")]
|
||||
#[test_case::test_case(&["otel", "environment"], Some("otel.environment"); "environment")]
|
||||
#[test_case::test_case(&["otel", "exporter", "otlp-http", "endpoint"], Some("otel.exporter"); "exporter_endpoint")]
|
||||
#[test_case::test_case(&["otel", "trace_exporter"], Some("otel.trace_exporter"); "trace_exporter")]
|
||||
#[test_case::test_case(&["otel", "metrics_exporter"], Some("otel.metrics_exporter"); "metrics_exporter")]
|
||||
#[test_case::test_case(&["otel", "span_attributes"], Some("otel.span_attributes"); "span_attributes")]
|
||||
#[test_case::test_case(&["otel", "span_attributes", "service.name"], Some("otel.span_attributes"); "span_attributes_service_name")]
|
||||
#[test_case::test_case(&["otel", "span_attributes", "other"], None; "span_attributes_other")]
|
||||
#[test_case::test_case(&["otel", "tracestate"], Some("otel.tracestate"); "tracestate")]
|
||||
#[test_case::test_case(&["otel", "tracestate", "managed", "tenant"], Some("otel.tracestate"); "tracestate_managed_tenant")]
|
||||
#[test_case::test_case(&["otel", "tracestate", "managed"], Some("otel.tracestate"); "tracestate_managed")]
|
||||
#[test_case::test_case(&["otel", "tracestate", "managed", "region"], None; "tracestate_managed_region")]
|
||||
#[test_case::test_case(&["otel", "tracestate", "other"], None; "tracestate_other")]
|
||||
#[test_case::test_case(&["otel", "tracestate", "empty"], None; "tracestate_empty")]
|
||||
fn otel_requirements_project_exact_values_and_lock_only_managed_map_entries(
|
||||
#[test_case::test_case(&["otel", "environment"], None; "environment_ignored")]
|
||||
#[test_case::test_case(&["otel", "exporter", "otlp-http", "endpoint"], None; "exporter_ignored")]
|
||||
#[test_case::test_case(&["otel", "trace_exporter"], None; "trace_exporter_ignored")]
|
||||
#[test_case::test_case(&["otel", "metrics_exporter"], None; "metrics_exporter_ignored")]
|
||||
#[test_case::test_case(&["otel", "span_attributes"], None; "span_attributes_ignored")]
|
||||
#[test_case::test_case(&["otel", "tracestate"], None; "tracestate_ignored")]
|
||||
fn otel_requirements_project_local_logging_values_and_ignore_exporter_keys(
|
||||
segments: &[&str],
|
||||
expected: Option<&str>,
|
||||
) -> Result<()> {
|
||||
// Former exporter keys still parse (for compatibility) but are ignored.
|
||||
let requirements: ConfigRequirementsToml = from_str(
|
||||
r#"
|
||||
[otel]
|
||||
@@ -2709,7 +2623,7 @@ environment = "managed"
|
||||
log_sse_deltas = false
|
||||
exporter = "none"
|
||||
trace_exporter = "none"
|
||||
metrics_exporter = "none"
|
||||
metrics_exporter = "statsig"
|
||||
span_attributes = { "service.name" = "managed" }
|
||||
tracestate = { managed = { tenant = "enterprise" }, empty = {} }
|
||||
"#,
|
||||
@@ -2724,8 +2638,6 @@ log_sse_deltas = true
|
||||
exporter = "statsig"
|
||||
trace_exporter = { otlp-grpc = { endpoint = "https://user.example" } }
|
||||
metrics_exporter = "statsig"
|
||||
span_attributes = { "service.name" = "user", other = "preserved" }
|
||||
tracestate = { managed = { tenant = "user", region = "us" }, other = { keep = "yes" } }
|
||||
"#,
|
||||
)?;
|
||||
|
||||
@@ -2737,13 +2649,7 @@ tracestate = { managed = { tenant = "user", region = "us" }, other = { keep = "y
|
||||
[otel]
|
||||
tool_result = { max_bytes = 1024 }
|
||||
log_user_prompt = false
|
||||
environment = "managed"
|
||||
log_sse_deltas = false
|
||||
exporter = "none"
|
||||
trace_exporter = "none"
|
||||
metrics_exporter = "none"
|
||||
span_attributes = { "service.name" = "managed", other = "preserved" }
|
||||
tracestate = { managed = { tenant = "enterprise", region = "us" }, other = { keep = "yes" } }
|
||||
"#
|
||||
)?
|
||||
);
|
||||
@@ -2758,7 +2664,7 @@ tracestate = { managed = { tenant = "enterprise", region = "us" }, other = { kee
|
||||
for empty in [
|
||||
"[otel]",
|
||||
"[otel.span_attributes]",
|
||||
"[otel.tracestate.empty]",
|
||||
"[otel]\nexporter = \"statsig\"",
|
||||
] {
|
||||
let requirements: ConfigRequirementsToml = from_str(empty)?;
|
||||
assert!(requirements.is_empty(), "{empty}");
|
||||
@@ -3441,7 +3347,7 @@ tracestate = { managed = { tenant = "enterprise", region = "us" }, other = { kee
|
||||
plugins: None,
|
||||
marketplaces: None,
|
||||
otel: Some(Box::new(OtelRequirementsToml {
|
||||
environment: Some("managed".to_string()),
|
||||
log_user_prompt: Some(true),
|
||||
..Default::default()
|
||||
})),
|
||||
apps: None,
|
||||
@@ -3539,7 +3445,7 @@ tracestate = { managed = { tenant = "enterprise", region = "us" }, other = { kee
|
||||
marketplaces: None,
|
||||
otel: Some(Box::new(Sourced::new(
|
||||
OtelRequirementsToml {
|
||||
environment: Some("managed".to_string()),
|
||||
log_user_prompt: Some(true),
|
||||
..Default::default()
|
||||
},
|
||||
source.clone(),
|
||||
|
||||
@@ -11,7 +11,6 @@ use crate::browser_use::BrowserUseConfigToml;
|
||||
use crate::computer_use::ComputerUseConfigToml;
|
||||
use crate::permissions_toml::PermissionsToml;
|
||||
use crate::profile_toml::ConfigProfile;
|
||||
use crate::types::AnalyticsConfigToml;
|
||||
use crate::types::ApprovalsReviewer;
|
||||
use crate::types::AppsConfigToml;
|
||||
use crate::types::AuthCredentialsStoreMode;
|
||||
@@ -535,11 +534,6 @@ pub struct ConfigToml {
|
||||
/// Legacy fallback for `tui.disable_paste_burst`. Prefer the setting under `[tui]`.
|
||||
pub disable_paste_burst: Option<bool>,
|
||||
|
||||
/// When `enabled` is `false`, disables OpenAI analytics across Codex product surfaces on this machine.
|
||||
/// Custom OTLP metrics exporters are controlled by `otel.metrics_exporter`.
|
||||
/// When unset, the default depends on the client.
|
||||
pub analytics: Option<AnalyticsConfigToml>,
|
||||
|
||||
/// When `false`, disables feedback collection across Codex product surfaces.
|
||||
/// Defaults to `true`.
|
||||
pub feedback: Option<FeedbackConfigToml>,
|
||||
@@ -552,7 +546,7 @@ pub struct ConfigToml {
|
||||
#[serde(default)]
|
||||
pub desktop: Option<HashMap<String, JsonValue>>,
|
||||
|
||||
/// OTEL configuration.
|
||||
/// Local logging settings (historical `[otel]` table; nothing is exported).
|
||||
pub otel: Option<OtelConfigToml>,
|
||||
|
||||
/// Windows-specific configuration.
|
||||
|
||||
@@ -4,7 +4,6 @@ use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config_toml::ToolsToml;
|
||||
use crate::types::AnalyticsConfigToml;
|
||||
use crate::types::ApprovalsReviewer;
|
||||
use crate::types::Personality;
|
||||
use crate::types::SessionPickerViewMode;
|
||||
@@ -59,7 +58,6 @@ pub struct ConfigProfile {
|
||||
pub experimental_use_unified_exec_tool: Option<bool>,
|
||||
pub tools: Option<ToolsToml>,
|
||||
pub web_search: Option<WebSearchMode>,
|
||||
pub analytics: Option<AnalyticsConfigToml>,
|
||||
/// TUI settings scoped to this profile.
|
||||
#[serde(default)]
|
||||
pub tui: Option<ProfileTui>,
|
||||
|
||||
@@ -341,7 +341,7 @@ refresh_interval_ms = 12345
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn otel_requirements_compose_exact_values_atomic_exporters_and_metadata() {
|
||||
fn otel_requirements_compose_exact_values_and_ignore_legacy_exporter_keys() {
|
||||
let low_dir = tempdir().expect("low-priority requirements directory");
|
||||
let high_dir = tempdir().expect("high-priority requirements directory");
|
||||
let low_base = AbsolutePathBuf::from_absolute_path(low_dir.path()).expect("absolute low base");
|
||||
@@ -421,16 +421,10 @@ tracestate = { shared = { tenant = "replacement", region = "us" }, lower = { ten
|
||||
composed.value,
|
||||
*expected_requirements(expected).otel.unwrap()
|
||||
);
|
||||
assert_eq!(
|
||||
compose(vec![layer(
|
||||
"mixed",
|
||||
"Mixed",
|
||||
"[otel]\nexporter = 'none'\nspan_attributes = {}\ntracestate = { empty = {} }",
|
||||
)]),
|
||||
Ok(Some(expected_requirements("[otel]\nexporter = 'none'"))),
|
||||
);
|
||||
|
||||
// Legacy exporter/metadata keys are accepted but ignored, so a layer that
|
||||
// only sets them contributes no OTEL requirements.
|
||||
for empty in [
|
||||
"[otel]\nexporter = 'none'\nspan_attributes = {}\ntracestate = { empty = {} }",
|
||||
"[otel]",
|
||||
"[otel.span_attributes]",
|
||||
"[otel.tracestate.empty]",
|
||||
|
||||
@@ -30,7 +30,6 @@ use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
|
||||
use codex_utils_redacted_string::RedactedString;
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
@@ -53,7 +52,6 @@ pub use crate::tui_keymap::TuiVimOperatorKeymap;
|
||||
pub use crate::tui_keymap::TuiVimSearchKeymap;
|
||||
pub use crate::tui_rendering::TuiRendering;
|
||||
|
||||
pub const DEFAULT_OTEL_ENVIRONMENT: &str = "dev";
|
||||
pub const DEFAULT_MEMORIES_MAX_ROLLOUTS_PER_STARTUP: usize = 2;
|
||||
pub const DEFAULT_MEMORIES_MAX_ROLLOUT_AGE_DAYS: i64 = 10;
|
||||
pub const DEFAULT_MEMORIES_MIN_ROLLOUT_IDLE_HOURS: i64 = 6;
|
||||
@@ -242,21 +240,10 @@ pub enum HistoryPersistence {
|
||||
None,
|
||||
}
|
||||
|
||||
// ===== Analytics configuration =====
|
||||
|
||||
/// Analytics settings loaded from config.toml. Fields are optional so we can apply defaults.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default, JsonSchema)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
pub struct AnalyticsConfigToml {
|
||||
/// When `false`, disables OpenAI analytics across Codex product surfaces in this profile.
|
||||
/// Custom OTLP metrics exporters remain enabled; set `otel.metrics_exporter = "none"` to disable them.
|
||||
pub enabled: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default, JsonSchema)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
pub struct FeedbackConfigToml {
|
||||
/// When `false`, disables feedback uploads and background Guardian review retention. Explicit local exports remain available.
|
||||
/// When `false`, disables feedback collection and background Guardian review retention. Explicit local exports remain available.
|
||||
pub enabled: Option<bool>,
|
||||
}
|
||||
|
||||
@@ -589,102 +576,29 @@ pub struct AppsConfigToml {
|
||||
|
||||
// ===== OTEL configuration =====
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum OtelHttpProtocol {
|
||||
/// Binary payload
|
||||
Binary,
|
||||
/// JSON payload
|
||||
Json,
|
||||
}
|
||||
|
||||
/// Local logging settings kept under the historical `[otel]` table.
|
||||
///
|
||||
/// aKode never exports telemetry. The former exporter keys (`exporter`,
|
||||
/// `trace_exporter`, `metrics_exporter`, `environment`, `span_attributes`,
|
||||
/// `tracestate`, `log_agent_responses`, `log_guardian_assessments`) are still
|
||||
/// accepted in `config.toml` for compatibility but are ignored.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default, JsonSchema)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct OtelTlsConfig {
|
||||
pub ca_certificate: Option<AbsolutePathBuf>,
|
||||
pub client_certificate: Option<AbsolutePathBuf>,
|
||||
pub client_private_key: Option<AbsolutePathBuf>,
|
||||
}
|
||||
|
||||
/// Which OTEL exporter to use.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum OtelExporterKind {
|
||||
None,
|
||||
Statsig,
|
||||
OtlpHttp {
|
||||
endpoint: String,
|
||||
#[serde(default)]
|
||||
#[schemars(with = "HashMap<String, String>")]
|
||||
headers: HashMap<String, RedactedString>,
|
||||
protocol: OtelHttpProtocol,
|
||||
#[serde(default)]
|
||||
tls: Option<OtelTlsConfig>,
|
||||
},
|
||||
OtlpGrpc {
|
||||
endpoint: String,
|
||||
#[serde(default)]
|
||||
#[schemars(with = "HashMap<String, String>")]
|
||||
headers: HashMap<String, RedactedString>,
|
||||
#[serde(default)]
|
||||
tls: Option<OtelTlsConfig>,
|
||||
},
|
||||
}
|
||||
|
||||
/// OTEL settings loaded from config.toml. Fields are optional so we can apply defaults.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default, JsonSchema)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
pub struct OtelConfigToml {
|
||||
/// Byte limit for tool-result log output; independent of model-visible output.
|
||||
pub tool_result: Option<codex_protocol::config_types::ToolResultLogConfig>,
|
||||
/// Log successful SSE events whose kind ends in `.delta`. Defaults to true.
|
||||
/// Disabling this preserves errors, completion events, and metrics.
|
||||
/// Disabling this preserves errors and completion events.
|
||||
pub log_sse_deltas: Option<bool>,
|
||||
/// Log user prompt in traces
|
||||
/// Include the user prompt in local log events.
|
||||
pub log_user_prompt: Option<bool>,
|
||||
/// Opt in to logging final main-agent and spawned-subagent responses to an OTLP log exporter.
|
||||
/// Defaults to false. Response text can be sensitive and is capped at 64 KiB.
|
||||
pub log_agent_responses: Option<bool>,
|
||||
/// Opt in to logging completed Guardian assessments to an OTLP log exporter.
|
||||
/// Defaults to false. Rationales can be sensitive and are capped at 64 KiB.
|
||||
pub log_guardian_assessments: Option<bool>,
|
||||
|
||||
/// Mark traces with environment (dev, staging, prod, test). Defaults to dev.
|
||||
pub environment: Option<String>,
|
||||
|
||||
/// Optional log exporter
|
||||
pub exporter: Option<OtelExporterKind>,
|
||||
|
||||
/// Optional trace exporter
|
||||
pub trace_exporter: Option<OtelExporterKind>,
|
||||
|
||||
/// Metrics exporter. Defaults to `statsig`, which follows `analytics.enabled`.
|
||||
/// Custom OTLP exporters are independent of `analytics.enabled`; `none` disables metrics export.
|
||||
pub metrics_exporter: Option<OtelExporterKind>,
|
||||
|
||||
/// Attributes to add to every exported trace span.
|
||||
pub span_attributes: Option<HashMap<String, String>>,
|
||||
|
||||
/// Semicolon-separated `key:value` fields to upsert into W3C tracestate members.
|
||||
pub tracestate: Option<BTreeMap<String, BTreeMap<String, String>>>,
|
||||
}
|
||||
|
||||
/// Effective OTEL settings after defaults are applied.
|
||||
/// Effective local logging settings after defaults are applied.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct OtelConfig {
|
||||
pub tool_result: codex_protocol::config_types::ToolResultLogConfig,
|
||||
pub log_sse_deltas: bool,
|
||||
pub log_user_prompt: bool,
|
||||
pub log_agent_responses: bool,
|
||||
pub log_guardian_assessments: bool,
|
||||
pub environment: String,
|
||||
pub exporter: OtelExporterKind,
|
||||
pub trace_exporter: OtelExporterKind,
|
||||
pub metrics_exporter: OtelExporterKind,
|
||||
pub span_attributes: HashMap<String, String>,
|
||||
pub tracestate: BTreeMap<String, BTreeMap<String, String>>,
|
||||
}
|
||||
|
||||
impl Default for OtelConfig {
|
||||
@@ -693,38 +607,10 @@ impl Default for OtelConfig {
|
||||
tool_result: Default::default(),
|
||||
log_sse_deltas: true,
|
||||
log_user_prompt: false,
|
||||
log_agent_responses: false,
|
||||
log_guardian_assessments: false,
|
||||
environment: DEFAULT_OTEL_ENVIRONMENT.to_owned(),
|
||||
exporter: OtelExporterKind::None,
|
||||
trace_exporter: OtelExporterKind::None,
|
||||
metrics_exporter: OtelExporterKind::None,
|
||||
span_attributes: HashMap::new(),
|
||||
tracestate: BTreeMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl OtelConfig {
|
||||
/// Response text requires a separate opt-in and an explicit OTLP log destination.
|
||||
pub fn agent_response_logging_enabled(&self) -> bool {
|
||||
self.log_agent_responses
|
||||
&& matches!(
|
||||
self.exporter,
|
||||
OtelExporterKind::OtlpHttp { .. } | OtelExporterKind::OtlpGrpc { .. }
|
||||
)
|
||||
}
|
||||
|
||||
/// Assessment text requires an explicit opt-in and an OTLP log destination.
|
||||
pub fn guardian_assessment_logging_enabled(&self) -> bool {
|
||||
self.log_guardian_assessments
|
||||
&& matches!(
|
||||
self.exporter,
|
||||
OtelExporterKind::OtlpHttp { .. } | OtelExporterKind::OtlpGrpc { .. }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Clone, PartialEq, Eq, Deserialize, JsonSchema)]
|
||||
#[serde(untagged)]
|
||||
pub enum Notifications {
|
||||
|
||||
Reference in New Issue
Block a user