langwatch codexstarts Codex and sets up the connection on the first run. Use it on a machine you work on.langwatch instrument codexwrites the same setup and exits. Use it on a server, or when the telemetry must go to a team project.
codex run also reports to LangWatch. The connection lives in ~/.codex/config.toml, so it stays after you close the terminal.
Before you start
- Install the Codex command line tool.
- Install the LangWatch command line tool:
npm install -g langwatch - Create an account at app.langwatch.ai, or run your own instance with
npx @langwatch/server.
Run Codex through the wrapper
LangWatch remembers the answer, so later runs do not ask again. Everything else is unchanged:
langwatch codex accepts the same flags and the same subcommands as codex, and it returns the same exit code.
A virtual key is created the first time you choose the gateway, not at login. If you always keep your own subscription, LangWatch never creates one for you.
Set up a machine without starting Codex
langwatch instrument codex writes the connection into ~/.codex/config.toml and exits. A plain codex run on that machine then sends its telemetry to LangWatch. This is the setup for a server that holds many agents, for a machine image, or for a configuration management run.
Choose where the telemetry goes
Pass one scope flag, and one only.Send the telemetry to a team project
traces:create permission on the project. See Roles and permissions.
The wrapper accepts the same flags. This pins the project and then starts Codex:
--project and --personal are LangWatch flags. LangWatch removes them from the command line before Codex reads it, so they never reach the agent.
Set up a machine that never logs in
--key takes an ingest key (ik-lw-…). It needs no login and contacts no server, which makes it the option for a shared machine, a build agent, or a base image.
LANGWATCH_INGEST_KEY environment variable:
Move a tool back to your personal workspace
Remove the setup
What you get in LangWatch
Open your personal page at/me, or open the project you pinned Codex to.
- Sessions: one row per Codex session, with the context it carried, how long it worked, and the pull requests it drove.
- Traces: one trace per turn, with the model, the tokens and the timing of each step.
- Cost: the amount per session and per turn.
- Content: the prompt of each turn, each tool call with its result, and the answer of the model.
Content and privacy
Content reaches LangWatch on one path only, and you can turn that path off. Codex’s own OpenTelemetry export carries no conversation content; thenotify program LangWatch installs does send it. Read both parts below before you decide.
The OpenTelemetry export carries two signals. The trace exporter reports each turn with the model, the tokens and the timing. The event exporter reports the facts of the session: each tool run with its name, duration and result, each prompt as a length without its text, tool approvals and denials, and the time to the first token. LangWatch enables both, and the session view is built from them. The prompt text, the tool output and the answer never ride either signal, and no Codex setting turns that content on. So the [otel] block alone gives you usage numbers and nothing that was said.
Codex does write the whole conversation to a transcript on your machine, and each turn there records the trace that Codex reported it under. langwatch codex and langwatch instrument codex register a small program on the Codex notify setting, which Codex runs after each completed turn. That program reads the turn from the transcript and records it against the same trace, so a session you started with a plain codex still shows what was said. This is the path that carries content, and LangWatch installs it unless you say otherwise. A notify program of your own keeps running: LangWatch calls it after its own.
To collect the usage numbers and no content, remove the notify setting from ~/.codex/config.toml and keep the [otel] block. Tokens, cost, model, timing, tool counts and prompt lengths continue.
Troubleshooting
Nothing arrives in LangWatch
Nothing arrives in LangWatch
Run
langwatch instrument codex again and read what it prints. It names the file it wrote and the destination the telemetry goes to.Then check that ~/.codex/config.toml holds a [otel] block between the two LangWatch marker lines.Traces arrive but every turn is empty
Traces arrive but every turn is empty
The turn program is missing. It is the part that recovers the conversation, because Codex itself exports no content. Run
langwatch instrument codex again and read the result.If it reports that your Codex configuration already runs a program of its own after every turn and cannot be moved safely, remove the notify setting from ~/.codex/config.toml and run the command again.Traces arrive but the session shows no tools or prompts
Traces arrive but the session shows no tools or prompts
Codex separates the exporters by signal:
[otel.trace_exporter.otlp-http] sends the spans and [otel.exporter.otlp-http] sends the events that carry the tool runs and the prompt lengths. A configuration written before the event exporter was part of the block only has the first one. Run langwatch instrument codex again to write both.The endpoint returns 404
The endpoint returns 404
Codex does not append the signal path to the endpoint, unlike most OpenTelemetry libraries. Write the full path per exporter:
https://app.langwatch.ai/api/otel/v1/traces on the trace exporter and https://app.langwatch.ai/api/otel/v1/logs on the event exporter.The telemetry goes to the wrong workspace
The telemetry goes to the wrong workspace
Run
langwatch instrument codex --project <id-or-slug> to move it to a team project, or langwatch instrument codex --personal to move it back to your own.Authentication errors
Authentication errors
Check that the key is live and that the header reads
Authorization = "Bearer <key>". An ingest key can write traces and nothing else, so a key that works for ingestion still fails on other endpoints.On a machine with a login, run langwatch login --device again to refresh the session.Manual OpenTelemetry setup
Use this when you cannot install the LangWatch command line tool. The block below is the onelangwatch instrument codex writes for you.
Add it to ~/.codex/config.toml:
ik-lw-…), which can create traces and nothing else. Keep a full project API key (sk-lw-…) out of the configuration of a coding agent: it can read and change your project data, and a coding agent has no use for that.
Then set the file to owner-only permissions, because it holds a key:
/api/otel/v1/traces and /api/otel/v1/logs paths.
The
environment value is a free label. It arrives on every trace, so a name such as your organization or your team makes the traces easier to filter.langwatch instrument codex installs.