Connect Codex to LinearB using OpenTelemetry
Connect Codex to LinearB using OpenTelemetry to track adoption, accepted lines of code, token consumption, models, and estimated cost.
Overview
Connect Codex to LinearB using OpenTelemetry to collect Codex usage data and analyze AI adoption and usage in LinearB.
The integration provides Codex adoption, accepted lines of code, token consumption, model, and estimated cost data.
Data Provided by Codex
The Codex OpenTelemetry integration provides the following data in LinearB:
- Adoption
- Accepted lines of code (LOC)
- Token consumption
- Models
- Estimated cost
Before You Begin
Before configuring the integration:
- Make sure you have access to AI Tools settings in LinearB.
- Make sure developers use the Codex CLI or IDE extension. Codex on the web does not send OpenTelemetry data.
- Decide whether Codex telemetry will be sent through an OpenTelemetry Collector or directly to LinearB. LinearB recommends using an OpenTelemetry Collector.
- Keep the LinearB ingest token secure. It is used to authenticate telemetry sent to LinearB.
Add the Codex OpenTelemetry Integration
- Go to Settings → Company Settings → AI Tools → Integrations.
- Click Add New.
- Select Codex.
- Select OpenTelemetry as the connection type.
- Continue to the integration settings.
LinearB generates a write-only Ingest Token and displays the OpenTelemetry configuration required to send Codex telemetry to LinearB.
Choose How Codex Telemetry Reaches LinearB
LinearB supports two methods for sending Codex OpenTelemetry data:
Via OpenTelemetry Collector (Recommended)
LinearB recommends using an OpenTelemetry Collector. The Collector runs on each developer machine and filters Codex telemetry locally before sending the required data to LinearB.
The Collector strips apply_patch arguments locally, so code
changes contained in those events do not leave the developer machine.
Direct to LinearB
Select Direct to LinearB to send Codex telemetry directly to LinearB without an intermediate Collector.
apply_patch arguments containing your code changes, is stored
by LinearB. Use the OpenTelemetry Collector to keep that data in your
environment.
Configure Codex Telemetry
-
In the Codex integration, choose:
- Via OpenTelemetry Collector (recommended), or
- Direct to LinearB.
- Select the operating system used by the developer machine: macOS, Linux, or Windows.
- Review the values displayed under Values.
- Copy the configuration generated by LinearB for the selected operating system and connection method.
- Apply the generated configuration to Codex.
- Restart Codex.
Configure an Individual User
For an individual Codex user, add the configuration generated by LinearB to:
~/.codex/config.toml
Restart Codex after applying the configuration.
Configure Codex Organization-Wide
For an organization-wide managed configuration, add the configuration to:
/etc/codex/managed_config.toml
IT administrators can distribute the managed configuration to developer machines using an MDM solution.
Restart Codex on each developer machine after the configuration is applied.
Using an OpenTelemetry Collector
When using the recommended Collector method, an OpenTelemetry Collector runs on each developer machine. The Collector filters Codex telemetry locally and forwards the required telemetry to LinearB.
Use the Collector configuration generated by LinearB when setting up the integration.
apply_patch arguments so that code changes contained
in those events remain in your environment.
Data Collection
Codex begins sending telemetry after the OpenTelemetry configuration is active and Codex has been restarted.
The integration's Last used value typically updates within minutes after LinearB receives telemetry. Usage data and metrics typically appear in LinearB within a few hours.
Manage the Ingest Token
LinearB generates a write-only ingest token for the Codex OpenTelemetry integration. The token authenticates telemetry sent to LinearB.
Rotate the Ingest Token
- Go to Settings → Company Settings → AI Tools → Integrations.
- Open the Codex OpenTelemetry integration.
- Under Main Settings, locate the Ingest Token.
- Click Rotate.
- Save the new token securely.
- Update your OpenTelemetry configuration to use the new token.
- Restart Codex after applying the updated configuration.
Verify the Connection
- Complete the OpenTelemetry configuration for Codex.
- Restart Codex.
- Use the Codex CLI or IDE extension to generate activity.
- In LinearB, go to Settings → Company Settings → AI Tools → Integrations.
- Open the Codex OpenTelemetry integration.
- Check Last used to confirm that telemetry has reached LinearB.
Last used typically updates within minutes. Usage data and metrics typically appear in LinearB within a few hours.
Edit the Integration
Open the Codex OpenTelemetry integration to review its current configuration. Use the available controls under Main Settings to update supported settings or rotate the ingest token.
Troubleshooting
Last Used Does Not Update
If Last used does not update after generating Codex activity:
- Confirm that you generated activity using the Codex CLI or IDE extension. Codex on the web does not send telemetry.
- Confirm that the current LinearB ingest token is used by the OpenTelemetry configuration.
- Verify that the generated configuration was added to the correct Codex configuration file.
- Confirm that Codex was restarted after the configuration was applied.
- For Collector-based configurations, confirm that the OpenTelemetry Collector is running on the developer machine.
- Confirm that telemetry can reach the configured LinearB endpoint.
Last Used Updates but Metrics Do Not Appear
If Last used is updating, LinearB is receiving telemetry from Codex. Usage data and metrics are processed separately and typically appear within a few hours.
Ingest Token Was Not Saved
If the ingest token is no longer available, click Rotate to generate a new token and update the OpenTelemetry configuration with the new value.
Integration Shows an Error
Open the integration and review the connection status and configuration. Verify the ingest token and OpenTelemetry configuration before retrying the connection.
How did we do?
Connect Claude Code using the Analytics API
Connect Codex to LinearB using the Analytics API