Observability for OpenAI Codex with Opik
OpenAI Codex supports opt-in OpenTelemetry export through Codex configuration files.
When this guide applies
Section titled “When this guide applies”Use this guide if you run Codex (CLI/IDE/app) and want its OTEL trace exporter to send telemetry to Opik.
Where to configure Codex
Section titled “Where to configure Codex”Codex reads configuration from:
- user config:
~/.codex/config.toml - project config:
.codex/config.toml
See Codex config basics.
Opik OTLP trace endpoint modes
Section titled “Opik OTLP trace endpoint modes”For Opik OTEL endpoint behavior, see Opik OpenTelemetry overview.
[otel]
environment = "prod"
log_user_prompt = false
[otel.trace_exporter.otlp-http]
endpoint = "https://www.comet.com/opik/api/v1/private/otel/v1/traces"
protocol = "binary"
headers = { "Authorization" = "<your-api-key>", "Comet-Workspace" = "<your-workspace>", "projectName" = "<your-project-name>" }Required headers:
AuthorizationComet-Workspace
Optional headers:
projectName(recommended)
[otel]
environment = "prod"
log_user_prompt = false
[otel.trace_exporter.otlp-http]
endpoint = "https://<comet-deployment-url>/opik/api/v1/private/otel/v1/traces"
protocol = "binary"
headers = { "Authorization" = "<your-api-key>", "Comet-Workspace" = "<your-workspace>", "projectName" = "<your-project-name>" }Required headers:
AuthorizationComet-Workspace
Optional headers:
projectName(recommended)
[otel]
environment = "prod"
log_user_prompt = false
[otel.trace_exporter.otlp-http]
endpoint = "http://localhost:5173/api/v1/private/otel/v1/traces"
protocol = "binary"
headers = { "projectName" = "<your-project-name>" }Required headers:
- none by default (depends on your self-hosted auth setup)
Optional headers:
projectName(recommended)- auth headers if your instance enforces auth
Example intent and minimal valid setup
Section titled “Example intent and minimal valid setup”Intent: Route Codex OTEL trace export to Opik with project/workspace attribution.
Applies when: You have enabled Codex OTEL export and selected OTLP/HTTP exporter in config.
Required fields:
- an
[otel.trace_exporter.otlp-http]table. The table itself selects the exporter; do not also writetrace_exporter = "otlp-http"as a string under[otel], Codex rejects the file withcannot extend value of type string with a dotted key. endpointprotocol(binaryorjson, binary recommended)
Optional fields:
headers(projectNamestrongly recommended)otel.environmentotel.log_user_prompt(keepfalseunless policy allows prompt export)
Minimal valid config:
[otel]
log_user_prompt = false
[otel.trace_exporter.otlp-http]
endpoint = "https://www.comet.com/opik/api/v1/private/otel/v1/traces"
protocol = "binary"
headers = { "Authorization" = "<your-api-key>", "Comet-Workspace" = "<your-workspace>", "projectName" = "<your-project-name>" }Validation
Section titled “Validation”- Run a Codex session after updating
config.toml. - Confirm OTLP HTTP requests are sent to
/otel/v1/traces. - Verify traces appear in the expected Opik workspace/project. Expect many short internal
traces per session (
auth,turn/start,codex.exec, ...); open asession_loopordispatch_tool_call_with_terminal_outcomespan and look under Metadata → opentelemetry.events for thecodex.*events.
- Codex telemetry export is opt-in.
- Prompt text and token usage are only available on the logs signal (
otel.exporter), which Opik does not receive. - Keep
log_user_prompt = falseunless your policy explicitly allows prompt text export. - If your Codex build uses a different exporter key path, align with your installed version's config reference.