Codex hook plugin that exports completed Codex turns and tool calls to Logfire using direct OTLP HTTP/JSON.
This plugin is separate from the main Logfire plugin:
logfirelets Codex query Logfire data and help instrument applications.logfire-exportersends Codex's own activity telemetry to Logfire.
The exporter deliberately does not emit a long-lived session root span. Each completed Stop hook exports one
root-level turn span in a deterministic trace derived from the Codex conversation/thread identity; tool spans are
children of that turn span.
The Codex plugin metadata lives in .codex-plugin/plugin.json and configures:
- display name Logfire Exporter
- category Coding
- capabilities Read and Write
- transparent SVG icon and Logfire pink brand color
- default prompts for checking hook installation and explaining the trace design
- hook configuration from
hooks/hooks.json
The installed hooks capture Codex lifecycle events:
| Hook | Purpose |
|---|---|
SessionStart |
Initialize local telemetry state for startup, resume, and clear events |
UserPromptSubmit |
Store the submitted prompt and turn metadata |
PostToolUse |
Store tool-call results so they can be exported as child spans |
Stop |
Export the completed turn and its tool spans to Logfire |
Add the published Pydantic marketplace to Codex:
codex plugin marketplace add pydantic/skillsThen enable Logfire Exporter from the Pydantic marketplace in the Codex plugin UI.
After enabling the plugin:
- Configure
LOGFIRE_TOKENin your shell environment or in${XDG_CONFIG_HOME:-~/.config}/logfire-exporter/config.env. - Restart Codex so hook configuration is loaded.
- Run
/hooksif Codex asks you to review or trust the plugin hooks. - Complete a new Codex turn; the exporter sends telemetry on the
Stophook.
For local development after changing the plugin:
./scripts/reload-codex-plugin.sh logfire-exporterA new Codex conversation may be required for updated hooks, icons, or metadata to load.
Configure credentials in:
${XDG_CONFIG_HOME:-~/.config}/logfire-exporter/config.env
The minimal config is:
LOGFIRE_TOKEN=<your Logfire write token>LOGFIRE_BASE_URL defaults to https://logfire-api.pydantic.dev. Set it only for another Logfire region or a local
Logfire instance. LOGFIRE_URL is still accepted as a compatibility alias, but LOGFIRE_BASE_URL takes precedence.
For a local Logfire instance:
LOGFIRE_BASE_URL=http://localhost:3000/
LOGFIRE_TOKEN=pylf_v1_local_zHhcVLNlKY921fl9jkN7vZ6P4gkL9w7h8HVG609xK5ym
CODEX_LOGFIRE_DEBUG=trueFor compatibility with local pre-release testing, the exporter will also read old config paths when the new config file does not exist.
The plugin sends Authorization: <LOGFIRE_TOKEN>, matching Logfire's direct OTLP client configuration. If you need a
scheme-prefixed header, set CODEX_LOGFIRE_AUTH_SCHEME=Bearer.
The exporter writes directly to Logfire's OTLP HTTP endpoint. It does not use the Logfire SDK or the OpenTelemetry SDK, which lets it control deterministic trace IDs and span IDs derived from Codex conversation metadata.
Trace IDs are deterministic. The exporter chooses the trace identity in this order:
- hook payload root/thread fields, if Codex exposes them
CODEX_THREAD_ID, when present in the hook environment- hook
session_idas the fallback
The selected value is exported as codex.conversation_id, while the hook session_id is exported separately as
codex.session_id.
By default the plugin uses CODEX_LOGFIRE_CONTENT_CAPTURE_MODE=full, so it exports redacted prompt text, final
assistant text, tool inputs, tool outputs, and tool errors.
To suppress captured content, set a narrower mode:
CODEX_LOGFIRE_CONTENT_CAPTURE_MODE=metadata_onlyCapture modes:
full: default; includes redacted user prompt, final assistant message, tool input/output, and tool errors.no_tool_content: includes redacted user prompt and final assistant message, but not tool input/output.metadata_only: no prompt, assistant, tool input, or tool output content.
The current plugin emits standard Logfire/OTel spans plus pydantic_ai.all_messages when content capture is enabled,
which lets Logfire show Codex turns in the generic LLM conversation/details panel.
Install logfire-exporter when you want telemetry about Codex itself. Install logfire when you want Codex to
help instrument applications, query existing Logfire data, or open Logfire UI views.
The two plugins can be enabled together.
Debug logs are written under:
${XDG_STATE_HOME:-~/.local/state}/logfire-exporter/logs/
If no spans or plugin logs appear after a completed Codex turn, check the Codex TUI log:
rg -n "logfire-exporter|failed to load plugin" ~/.codex/log/codex-tui.logFrom the repository root:
python3 -m unittest discover -s plugins/logfire-exporter/tests