mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
feat: support configurable metric_exporter (#10940)
This commit is contained in:
committed by
GitHub
Unverified
parent
3391e5ea86
commit
9fded117ac
@@ -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": [
|
||||
{
|
||||
|
||||
@@ -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()?;
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user