Skip to content

Implement OpenTelemetry support for Codex#181

Merged
AnnatarHe merged 2 commits intomainfrom
claude/add-otel-support-oelWL
Dec 30, 2025
Merged

Implement OpenTelemetry support for Codex#181
AnnatarHe merged 2 commits intomainfrom
claude/add-otel-support-oelWL

Conversation

@AnnatarHe
Copy link
Copy Markdown
Contributor

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

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
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @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 service.name attribute. This allows for intelligent routing and processing of metrics and events, incorporating Codex-specific data fields and event types into the existing telemetry pipeline. The update ensures that a single CCOtel gRPC server can efficiently collect and process data from multiple AI CLI tools, expanding its utility without requiring changes to the configuration.

Highlights

  • OpenTelemetry Support for Codex: The existing CCOtel workflow has been extended to support OpenAI Codex CLI, alongside Claude Code, by detecting the source from the service.name attribute in OpenTelemetry resources.
  • Source Detection and Routing: A new detectOtelSource() function identifies whether telemetry originates from 'claude-code' or 'codex' (including 'codex-cli' or 'openai-codex'), allowing the single CCOtel gRPC server to handle both.
  • Extended Data Model: The CCOtelRequest now includes a Source field to specify the CLI origin, and CCOtelEvent has new fields like ReasoningTokens and Provider to capture Codex-specific data.
  • Metric and Event Mapping: Metric and event name mappings have been updated to recognize and process codex.* prefixes, ensuring proper categorization of Codex-related telemetry.
  • Codex-Specific Event: A new event type, CCEventExecCommand, has been introduced to track shell command execution events originating from Codex.
  • Dynamic Project Detection: The detectProject() function now considers the CODEX_PROJECT environment variable when processing telemetry from Codex, in addition to existing methods.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 30, 2025

Codecov Report

❌ Patch coverage is 0% with 194 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
daemon/aicode_otel_processor.go 0.00% 111 Missing ⚠️
model/aicode_otel_env.go 0.00% 36 Missing ⚠️
model/api_aicode_otel.go 0.00% 16 Missing ⚠️
cmd/daemon/main.go 0.00% 8 Missing ⚠️
daemon/aicode_otel_server.go 0.00% 7 Missing ⚠️
commands/cc.go 0.00% 6 Missing ⚠️
model/config.go 0.00% 3 Missing and 3 partials ⚠️
commands/daemon.status.go 0.00% 4 Missing ⚠️
Flag Coverage Δ
unittests 20.19% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
commands/daemon.status.go 0.00% <0.00%> (ø)
commands/cc.go 0.00% <0.00%> (ø)
model/config.go 67.16% <0.00%> (ø)
daemon/aicode_otel_server.go 0.00% <0.00%> (ø)
cmd/daemon/main.go 0.00% <0.00%> (ø)
model/api_aicode_otel.go 0.00% <0.00%> (ø)
model/aicode_otel_env.go 0.00% <0.00%> (ø)
daemon/aicode_otel_processor.go 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread daemon/ccotel_processor.go Outdated
Comment on lines 325 to 333
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
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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)
@AnnatarHe AnnatarHe merged commit fc9afd3 into main Dec 30, 2025
2 of 3 checks passed
@AnnatarHe AnnatarHe deleted the claude/add-otel-support-oelWL branch December 30, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants