Skip to content

Commit f7615c5

Browse files
AnnatarHeclaude
andcommitted
feat(daemon): add missing Codex OTEL fields and aliases
Add support for missing Codex conversation_starts fields: - reasoning_effort, reasoning_summary - max_output_tokens, auto_compact_token_limit Add field name aliases per Codex OTEL docs: - provider_name → Provider - active_profile → Profile - cached_token_count, reasoning_token_count, tool_token_count 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7ea24ba commit f7615c5

2 files changed

Lines changed: 32 additions & 16 deletions

File tree

daemon/aicode_otel_processor.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,11 @@ func (p *AICodeOtelProcessor) parseLogRecord(lr *logsv1.LogRecord, resourceAttrs
427427
event.CostUSD = getFloatFromValue(value)
428428
case "duration_ms":
429429
event.DurationMs = getIntFromValue(value)
430-
case "input_tokens":
430+
case "input_tokens", "input_token_count":
431431
event.InputTokens = getIntFromValue(value)
432-
case "output_tokens":
432+
case "output_tokens", "output_token_count":
433433
event.OutputTokens = getIntFromValue(value)
434-
case "cache_read_tokens":
434+
case "cache_read_tokens", "cache_token_count", "cached_token_count", "cachedTokenCount":
435435
event.CacheReadTokens = getIntFromValue(value)
436436
case "cache_creation_tokens":
437437
event.CacheCreationTokens = getIntFromValue(value)
@@ -468,17 +468,17 @@ func (p *AICodeOtelProcessor) parseLogRecord(lr *logsv1.LogRecord, resourceAttrs
468468
case "language":
469469
event.Language = value.GetStringValue()
470470
// Codex-specific fields
471-
case "reasoning_tokens":
471+
case "reasoning_tokens", "reasoning_token_count", "reasoningTokenCount":
472472
event.ReasoningTokens = getIntFromValue(value)
473-
case "provider":
473+
case "provider", "provider_name", "providerName":
474474
event.Provider = value.GetStringValue()
475475
// Codex-specific fields for tool_decision
476476
case "call_id", "callId":
477477
event.CallID = value.GetStringValue()
478478
// Codex-specific fields for sse_event
479479
case "event_kind", "eventKind":
480480
event.EventKind = value.GetStringValue()
481-
case "tool_tokens", "toolTokens":
481+
case "tool_tokens", "toolTokens", "tool_token_count", "toolTokenCount":
482482
event.ToolTokens = getIntFromValue(value)
483483
// Codex-specific fields for conversation_starts
484484
case "auth_mode", "authMode":
@@ -493,12 +493,20 @@ func (p *AICodeOtelProcessor) parseLogRecord(lr *logsv1.LogRecord, resourceAttrs
493493
event.SandboxPolicy = value.GetStringValue()
494494
case "mcp_servers", "mcpServers":
495495
event.MCPServers = getStringArrayFromValue(value)
496-
case "profile":
496+
case "profile", "active_profile", "activeProfile":
497497
event.Profile = value.GetStringValue()
498498
case "reasoning_enabled", "reasoningEnabled":
499499
event.ReasoningEnabled = getBoolFromValue(value)
500+
case "reasoning_effort", "reasoningEffort":
501+
event.ReasoningEffort = value.GetStringValue()
502+
case "reasoning_summary", "reasoningSummary":
503+
event.ReasoningSummary = value.GetStringValue()
504+
case "max_output_tokens", "maxOutputTokens":
505+
event.MaxOutputTokens = getIntFromValue(value)
506+
case "auto_compact_token_limit", "autoCompactTokenLimit":
507+
event.AutoCompactTokenLimit = getIntFromValue(value)
500508
// Codex-specific fields for tool_result
501-
case "tool_arguments", "toolArguments":
509+
case "tool_arguments", "toolArguments", "arguments":
502510
if jsonStr := value.GetStringValue(); jsonStr != "" {
503511
var args map[string]interface{}
504512
if err := json.Unmarshal([]byte(jsonStr), &args); err == nil {
@@ -537,6 +545,10 @@ func (p *AICodeOtelProcessor) parseLogRecord(lr *logsv1.LogRecord, resourceAttrs
537545
return nil
538546
}
539547

548+
if event.SessionID == "" && event.ConversationID != "" {
549+
event.SessionID = event.ConversationID
550+
}
551+
540552
return event
541553
}
542554

model/aicode_otel_types.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,18 @@ type AICodeOtelEvent struct {
7474
ToolTokens int `json:"toolTokens,omitempty"`
7575

7676
// Codex-specific fields for conversation_starts
77-
AuthMode string `json:"authMode,omitempty"`
78-
Slug string `json:"slug,omitempty"`
79-
ContextWindow int `json:"contextWindow,omitempty"`
80-
ApprovalPolicy string `json:"approvalPolicy,omitempty"`
81-
SandboxPolicy string `json:"sandboxPolicy,omitempty"`
82-
MCPServers []string `json:"mcpServers,omitempty"`
83-
Profile string `json:"profile,omitempty"`
84-
ReasoningEnabled bool `json:"reasoningEnabled,omitempty"`
77+
AuthMode string `json:"authMode,omitempty"`
78+
Slug string `json:"slug,omitempty"`
79+
ContextWindow int `json:"contextWindow,omitempty"`
80+
ApprovalPolicy string `json:"approvalPolicy,omitempty"`
81+
SandboxPolicy string `json:"sandboxPolicy,omitempty"`
82+
MCPServers []string `json:"mcpServers,omitempty"`
83+
Profile string `json:"profile,omitempty"`
84+
ReasoningEnabled bool `json:"reasoningEnabled,omitempty"`
85+
ReasoningEffort string `json:"reasoningEffort,omitempty"`
86+
ReasoningSummary string `json:"reasoningSummary,omitempty"`
87+
MaxOutputTokens int `json:"maxOutputTokens,omitempty"`
88+
AutoCompactTokenLimit int `json:"autoCompactTokenLimit,omitempty"`
8589

8690
// Codex-specific fields for tool_result
8791
ToolArguments map[string]interface{} `json:"toolArguments,omitempty"`

0 commit comments

Comments
 (0)