Skip to content

exec ignores CODEX_INTERNAL_ORIGINATOR_OVERRIDE for OTEL service name #4821

Closed

Description

@andjohnsonj5

Summary

codex-exec 在启动时调用 set_default_originator("codex_exec") 先占住了全局 originator,因此即使设置了 CODEX_INTERNAL_ORIGINATOR_OVERRIDE 环境变量,OTEL 初始化也只会看到 codex_exec 这个值。

复现步骤

  1. 在 shell 中导出 CODEX_INTERNAL_ORIGINATOR_OVERRIDE=my_custom_client。
  2. 运行 codex-exec ... 启动一次对话。
  3. 检查导出的 OTEL trace(或本地 codex_otel 日志),service.name 始终是 codex_exec。

期望行为

OTEL 的 service.name 应该能反映 CODEX_INTERNAL_ORIGINATOR_OVERRIDE 的值,方便区分不同调用方或部署。

实际行为

codex-exec 在 codex-rs/exec/src/lib.rs:51 提前调用 set_default_originator("codex_exec"),导致 OnceLock 被占用;后续 codex-rs/core/src/default_client.rs:40 的 init_originator_from_env 无法读取环境变量。
OTEL 最终在 codex-rs/core/src/otel_init.rs:49 取到的 service_name 仍然是 codex_exec。

额外上下文

也许可以先检查环境变量是否已设置,或者允许环境变量覆写默认值,这样就能按客户端标识区分 OTEL 数据。

Activity

  1. added
    bug
    on Oct 6, 2025
  2. added
    exec
    on Nov 16, 2025
  3. added
    enterprise
    on Nov 28, 2025
  4. etraut-openai commented on Jan 13, 2026

    @etraut-openai
    Contributor

    Closing old bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenterpriseexec

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions