Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

feat: support configurable metric_exporter (#10940)

alexsong-oai9fded117ac23
diff --git a/codex-rs/core/config.schema.json b/codex-rs/core/config.schema.json
index 37e77a6b7d..2a45bf48be 100644
--- a/codex-rs/core/config.schema.json
+++ b/codex-rs/core/config.schema.json
@@ -611,6 +611,14 @@
"description": "Log user prompt in traces",
"type": "boolean"
},
+ "metrics_exporter": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/OtelExporterKind"
+ }
+ ],
+ "description": "Optional metrics exporter"
+ },
"trace_exporter": {
"allOf": [
{
diff --git a/codex-rs/core/src/config/mod.rs b/codex-rs/core/src/config/mod.rs
index 34a1772266..40d8a1f047 100644
--- a/codex-rs/core/src/config/mod.rs
+++ b/codex-rs/core/src/config/mod.rs
@@ -1808,12 +1808,13 @@ impl Config {
.unwrap_or(DEFAULT_OTEL_ENVIRONMENT.to_string());
let exporter = t.exporter.unwrap_or(OtelExporterKind::None);
let trace_exporter = t.trace_exporter.unwrap_or_else(|| exporter.clone());
+ let metrics_exporter = t.metrics_exporter.unwrap_or(OtelExporterKind::Statsig);
OtelConfig {
log_user_prompt,
environment,
exporter,
trace_exporter,
- metrics_exporter: OtelExporterKind::Statsig,
+ metrics_exporter,
}
},
};
@@ -4073,6 +4074,23 @@ model_verbosity = "high"
Ok(())
}
+ #[test]
+ fn metrics_exporter_defaults_to_statsig_when_missing() -> std::io::Result<()> {
+ let fixture = create_test_fixture()?;
+
+ let config = Config::load_from_base_config_with_overrides(
+ fixture.cfg.clone(),
+ ConfigOverrides {
+ cwd: Some(fixture.cwd()),
+ ..Default::default()
+ },
+ fixture.codex_home(),
+ )?;
+
+ assert_eq!(config.otel.metrics_exporter, OtelExporterKind::Statsig);
+ Ok(())
+ }
+
#[test]
fn test_precedence_fixture_with_gpt3_profile() -> std::io::Result<()> {
let fixture = create_test_fixture()?;
diff --git a/codex-rs/core/src/config/types.rs b/codex-rs/core/src/config/types.rs
index 3bc71006d3..32553d5a19 100644
--- a/codex-rs/core/src/config/types.rs
+++ b/codex-rs/core/src/config/types.rs
@@ -437,6 +437,9 @@ pub struct OtelConfigToml {
/// Optional trace exporter
pub trace_exporter: Option<OtelExporterKind>,
+
+ /// Optional metrics exporter
+ pub metrics_exporter: Option<OtelExporterKind>,
}
/// Effective OTEL settings after defaults are applied.