Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

add originator to otel (#10826)

alexsong-oaidaeef06becec
diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs
index 808ff43b42..93f87e5c44 100644
--- a/codex-rs/core/src/codex.rs
+++ b/codex-rs/core/src/codex.rs
@@ -981,6 +981,7 @@ impl Session {
auth.and_then(CodexAuth::get_account_id),
auth.and_then(CodexAuth::get_account_email),
auth_mode,
+ crate::default_client::originator().value,
config.otel.log_user_prompt,
terminal::user_agent(),
session_configuration.session_source.clone(),
@@ -5775,6 +5776,7 @@ mod tests {
None,
Some("[email protected]".to_string()),
Some(TelemetryAuthMode::Chatgpt),
+ "test_originator".to_string(),
false,
"test".to_string(),
session_source,
diff --git a/codex-rs/core/tests/responses_headers.rs b/codex-rs/core/tests/responses_headers.rs
index be8a93b0c1..ecd353a20d 100644
--- a/codex-rs/core/tests/responses_headers.rs
+++ b/codex-rs/core/tests/responses_headers.rs
@@ -80,6 +80,7 @@ async fn responses_stream_includes_subagent_header_on_review() {
None,
Some("[email protected]".to_string()),
Some(auth_mode),
+ "test_originator".to_string(),
false,
"test".to_string(),
session_source.clone(),
@@ -183,6 +184,7 @@ async fn responses_stream_includes_subagent_header_on_other() {
None,
Some("[email protected]".to_string()),
Some(auth_mode),
+ "test_originator".to_string(),
false,
"test".to_string(),
session_source.clone(),
@@ -285,6 +287,7 @@ async fn responses_respects_model_info_overrides_from_config() {
None,
Some("[email protected]".to_string()),
auth_mode,
+ "test_originator".to_string(),
false,
"test".to_string(),
session_source.clone(),
diff --git a/codex-rs/core/tests/suite/client.rs b/codex-rs/core/tests/suite/client.rs
index 46a51fe703..2b7753c294 100644
--- a/codex-rs/core/tests/suite/client.rs
+++ b/codex-rs/core/tests/suite/client.rs
@@ -1259,6 +1259,7 @@ async fn azure_responses_request_includes_store_and_reasoning_ids() {
None,
Some("[email protected]".to_string()),
auth_manager.auth_mode().map(TelemetryAuthMode::from),
+ "test_originator".to_string(),
false,
"test".to_string(),
SessionSource::Exec,
diff --git a/codex-rs/core/tests/suite/client_websockets.rs b/codex-rs/core/tests/suite/client_websockets.rs
index 125de9dfc5..a3810a2a3c 100644
--- a/codex-rs/core/tests/suite/client_websockets.rs
+++ b/codex-rs/core/tests/suite/client_websockets.rs
@@ -702,6 +702,7 @@ async fn websocket_harness_with_options(
None,
Some("[email protected]".to_string()),
auth_manager.auth_mode().map(TelemetryAuthMode::from),
+ "test_originator".to_string(),
false,
"test".to_string(),
SessionSource::Exec,
diff --git a/codex-rs/otel/src/lib.rs b/codex-rs/otel/src/lib.rs
index a86e5ef525..cbedc4836c 100644
--- a/codex-rs/otel/src/lib.rs
+++ b/codex-rs/otel/src/lib.rs
@@ -44,6 +44,7 @@ pub struct OtelEventMetadata {
pub(crate) auth_mode: Option<String>,
pub(crate) account_id: Option<String>,
pub(crate) account_email: Option<String>,
+ pub(crate) originator: String,
pub(crate) session_source: String,
pub(crate) model: String,
pub(crate) slug: String,
diff --git a/codex-rs/otel/src/traces/otel_manager.rs b/codex-rs/otel/src/traces/otel_manager.rs
index c54c64c6cb..8c0f5d2950 100644
--- a/codex-rs/otel/src/traces/otel_manager.rs
+++ b/codex-rs/otel/src/traces/otel_manager.rs
@@ -66,6 +66,7 @@ impl OtelManager {
account_id: Option<String>,
account_email: Option<String>,
auth_mode: Option<TelemetryAuthMode>,
+ originator: String,
log_user_prompts: bool,
terminal_type: String,
session_source: SessionSource,
@@ -76,6 +77,7 @@ impl OtelManager {
auth_mode: auth_mode.map(|m| m.to_string()),
account_id,
account_email,
+ originator,
session_source: session_source.to_string(),
model: model.to_owned(),
slug: slug.to_owned(),
@@ -134,6 +136,7 @@ impl OtelManager {
conversation.id = %self.metadata.conversation_id,
app.version = %self.metadata.app_version,
auth_mode = self.metadata.auth_mode,
+ originator = %self.metadata.originator,
user.account_id = self.metadata.account_id,
user.email = self.metadata.account_email,
terminal.type = %self.metadata.terminal_type,
@@ -198,6 +201,7 @@ impl OtelManager {
conversation.id = %self.metadata.conversation_id,
app.version = %self.metadata.app_version,
auth_mode = self.metadata.auth_mode,
+ originator = %self.metadata.originator,
user.account_id = self.metadata.account_id,
user.email = self.metadata.account_email,
terminal.type = %self.metadata.terminal_type,
@@ -229,6 +233,7 @@ impl OtelManager {
conversation.id = %self.metadata.conversation_id,
app.version = %self.metadata.app_version,
auth_mode = self.metadata.auth_mode,
+ originator = %self.metadata.originator,
user.account_id = self.metadata.account_id,
user.email = self.metadata.account_email,
terminal.type = %self.metadata.terminal_type,
@@ -330,6 +335,7 @@ impl OtelManager {
conversation.id = %self.metadata.conversation_id,
app.version = %self.metadata.app_version,
auth_mode = self.metadata.auth_mode,
+ originator = %self.metadata.originator,
user.account_id = self.metadata.account_id,
user.email = self.metadata.account_email,
terminal.type = %self.metadata.terminal_type,
@@ -407,6 +413,7 @@ impl OtelManager {
conversation.id = %self.metadata.conversation_id,
app.version = %self.metadata.app_version,
auth_mode = self.metadata.auth_mode,
+ originator = %self.metadata.originator,
user.account_id = self.metadata.account_id,
user.email = self.metadata.account_email,
terminal.type = %self.metadata.terminal_type,
@@ -440,6 +447,7 @@ impl OtelManager {
conversation.id = %self.metadata.conversation_id,
app.version = %self.metadata.app_version,
auth_mode = self.metadata.auth_mode,
+ originator = %self.metadata.originator,
user.account_id = self.metadata.account_id,
user.email = self.metadata.account_email,
terminal.type = %self.metadata.terminal_type,
@@ -455,6 +463,7 @@ impl OtelManager {
conversation.id = %self.metadata.conversation_id,
app.version = %self.metadata.app_version,
auth_mode = self.metadata.auth_mode,
+ originator = %self.metadata.originator,
user.account_id = self.metadata.account_id,
user.email = self.metadata.account_email,
terminal.type = %self.metadata.terminal_type,
@@ -478,6 +487,7 @@ impl OtelManager {
conversation.id = %self.metadata.conversation_id,
app.version = %self.metadata.app_version,
auth_mode = self.metadata.auth_mode,
+ originator = %self.metadata.originator,
user.account_id = self.metadata.account_id,
user.email = self.metadata.account_email,
terminal.type = %self.metadata.terminal_type,
@@ -503,6 +513,7 @@ impl OtelManager {
conversation.id = %self.metadata.conversation_id,
app.version = %self.metadata.app_version,
auth_mode = self.metadata.auth_mode,
+ originator = %self.metadata.originator,
user.account_id = self.metadata.account_id,
user.email = self.metadata.account_email,
terminal.type = %self.metadata.terminal_type,
@@ -538,6 +549,7 @@ impl OtelManager {
conversation.id = %self.metadata.conversation_id,
app.version = %self.metadata.app_version,
auth_mode = self.metadata.auth_mode,
+ originator = %self.metadata.originator,
user.account_id = self.metadata.account_id,
user.email = self.metadata.account_email,
terminal.type = %self.metadata.terminal_type,
@@ -562,6 +574,7 @@ impl OtelManager {
conversation.id = %self.metadata.conversation_id,
app.version = %self.metadata.app_version,
auth_mode = self.metadata.auth_mode,
+ originator = %self.metadata.originator,
user.account_id = self.metadata.account_id,
user.email = self.metadata.account_email,
terminal.type = %self.metadata.terminal_type,
@@ -617,6 +630,7 @@ impl OtelManager {
conversation.id = %self.metadata.conversation_id,
app.version = %self.metadata.app_version,
auth_mode = self.metadata.auth_mode,
+ originator = %self.metadata.originator,
user.account_id = self.metadata.account_id,
user.email = self.metadata.account_email,
terminal.type = %self.metadata.terminal_type,
@@ -654,6 +668,7 @@ impl OtelManager {
conversation.id = %self.metadata.conversation_id,
app.version = %self.metadata.app_version,
auth_mode = self.metadata.auth_mode,
+ originator = %self.metadata.originator,
user.account_id = self.metadata.account_id,
user.email = self.metadata.account_email,
terminal.type = %self.metadata.terminal_type,
diff --git a/codex-rs/otel/tests/suite/manager_metrics.rs b/codex-rs/otel/tests/suite/manager_metrics.rs
index 164bb43b3a..3dbc334417 100644
--- a/codex-rs/otel/tests/suite/manager_metrics.rs
+++ b/codex-rs/otel/tests/suite/manager_metrics.rs
@@ -23,6 +23,7 @@ fn manager_attaches_metadata_tags_to_metrics() -> Result<()> {
Some("account-id".to_string()),
None,
Some(TelemetryAuthMode::ApiKey),
+ "test_originator".to_string(),
true,
"tty".to_string(),
SessionSource::Cli,
@@ -77,6 +78,7 @@ fn manager_allows_disabling_metadata_tags() -> Result<()> {
Some("account-id".to_string()),
None,
Some(TelemetryAuthMode::ApiKey),
+ "test_originator".to_string(),
true,
"tty".to_string(),
SessionSource::Cli,
diff --git a/codex-rs/otel/tests/suite/runtime_summary.rs b/codex-rs/otel/tests/suite/runtime_summary.rs
index 79c6b258e7..0737e0797f 100644
--- a/codex-rs/otel/tests/suite/runtime_summary.rs
+++ b/codex-rs/otel/tests/suite/runtime_summary.rs
@@ -27,6 +27,7 @@ fn runtime_metrics_summary_collects_tool_api_and_streaming_metrics() -> Result<(
Some("account-id".to_string()),
None,
Some(TelemetryAuthMode::ApiKey),
+ "test_originator".to_string(),
true,
"tty".to_string(),
SessionSource::Cli,
diff --git a/codex-rs/otel/tests/suite/snapshot.rs b/codex-rs/otel/tests/suite/snapshot.rs
index aa7990d062..0c6ef7e914 100644
--- a/codex-rs/otel/tests/suite/snapshot.rs
+++ b/codex-rs/otel/tests/suite/snapshot.rs
@@ -76,6 +76,7 @@ fn manager_snapshot_metrics_collects_without_shutdown() -> Result<()> {
Some("account-id".to_string()),
None,
Some(TelemetryAuthMode::ApiKey),
+ "test_originator".to_string(),
true,
"tty".to_string(),
SessionSource::Cli,
diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs
index 718615237d..ea41749e92 100644
--- a/codex-rs/tui/src/app.rs
+++ b/codex-rs/tui/src/app.rs
@@ -986,6 +986,7 @@ impl App {
auth_ref.and_then(CodexAuth::get_account_id),
auth_ref.and_then(CodexAuth::get_account_email),
auth_mode,
+ codex_core::default_client::originator().value,
config.otel.log_user_prompt,
codex_core::terminal::user_agent(),
SessionSource::Cli,
@@ -2789,6 +2790,7 @@ mod tests {
None,
None,
None,
+ "test_originator".to_string(),
false,
"test".to_string(),
SessionSource::Cli,
diff --git a/codex-rs/tui/src/chatwidget/tests.rs b/codex-rs/tui/src/chatwidget/tests.rs
index 6d7df44119..7610d20757 100644
--- a/codex-rs/tui/src/chatwidget/tests.rs
+++ b/codex-rs/tui/src/chatwidget/tests.rs
@@ -896,6 +896,7 @@ fn test_otel_manager(config: &Config, model: &str) -> OtelManager {
None,
None,
None,
+ "test_originator".to_string(),
false,
"test".to_string(),
SessionSource::Cli,