Implement OpenTelemetry support for Codex#181
Conversation
Extend the existing CCOtel workflow to support both Claude Code and
OpenAI Codex CLI by detecting the source from service.name attribute.
Changes:
- Add detectOtelSource() to identify claude-code vs codex from service.name
- Add Source field to CCOtelRequest to identify CLI origin
- Extend metric/event name mappings for codex.* prefixes
- Add ReasoningTokens and Provider fields for Codex-specific data
- Add CCEventExecCommand for Codex shell command execution events
- Update detectProject() to check CODEX_PROJECT env var for Codex
The single CCOtel gRPC server now handles both:
- Claude Code (service.name: "claude-code")
- Codex CLI (service.name: "codex", "codex-cli", or "openai-codex")
Configuration remains unchanged - just enable ccotel in config.yaml:
ccotel:
enabled: true
grpcPort: 54027
Summary of ChangesHello @AnnatarHe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the OpenTelemetry (OTEL) integration by enabling the CCOtel processor to seamlessly handle telemetry data from both Claude Code and OpenAI Codex CLI. The core change involves introducing a robust mechanism to identify the source of OTEL resources based on their Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request extends the CCOtel service to support both Claude Code and Codex by introducing a source detection mechanism. The changes involve updating metric and log processing to identify the source, modifying data models (CCOtelRequest, CCOtelEvent) to include a source field and Codex-specific attributes like reasoningTokens and provider, and expanding metric/event name mapping to handle both claude_code.* and codex.* prefixes. The detectProject function was also updated to use source-specific environment variables. A review comment suggests refactoring the environment variable check within the detectProject function from an if-else if chain to a switch statement for improved readability and future extensibility.
| if source == model.CCOtelSourceClaudeCode { | ||
| if project := os.Getenv("CLAUDE_CODE_PROJECT"); project != "" { | ||
| return project | ||
| } | ||
| } else if source == model.CCOtelSourceCodex { | ||
| if project := os.Getenv("CODEX_PROJECT"); project != "" { | ||
| return project | ||
| } | ||
| } |
There was a problem hiding this comment.
This if-else if chain for checking environment variables based on the source can be refactored into a switch statement. This would improve readability and make it easier to add more sources in the future.
| if source == model.CCOtelSourceClaudeCode { | |
| if project := os.Getenv("CLAUDE_CODE_PROJECT"); project != "" { | |
| return project | |
| } | |
| } else if source == model.CCOtelSourceCodex { | |
| if project := os.Getenv("CODEX_PROJECT"); project != "" { | |
| return project | |
| } | |
| } | |
| switch source { | |
| case model.CCOtelSourceClaudeCode: | |
| if project := os.Getenv("CLAUDE_CODE_PROJECT"); project != "" { | |
| return project | |
| } | |
| case model.CCOtelSourceCodex: | |
| if project := os.Getenv("CODEX_PROJECT"); project != "" { | |
| return project | |
| } | |
| } |
Rename all CCOtel references to AICodeOtel to better reflect that the OTEL processor supports multiple AI coding CLIs (Claude Code, Codex, etc.) rather than just Claude Code. Changes: - Rename config type CCOtel -> AICodeOtel in model/types.go - Rename files: ccotel_*.go -> aicode_otel_*.go - Update all type names: CCOtel* -> AICodeOtel* - Update configuration keys: ccotel.* -> aiCodeOtel.* - Update documentation (CLAUDE.md, CONFIG.md)
Extend the existing CCOtel workflow to support both Claude Code and OpenAI Codex CLI by detecting the source from service.name attribute.
Changes:
The single CCOtel gRPC server now handles both:
Configuration remains unchanged - just enable ccotel in config.yaml:
ccotel:
enabled: true
grpcPort: 54027