-
Notifications
You must be signed in to change notification settings - Fork 0
fix(daemon): handle bool values sent as strings in OTEL processor #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -408,9 +408,15 @@ func (p *CCOtelProcessor) parseLogRecord(lr *logsv1.LogRecord, resourceAttrs *mo | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "tool_name": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| event.ToolName = value.GetStringValue() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "success": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| event.Success = value.GetBoolValue() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| event.Success = getBoolFromValue(value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "decision": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| event.Decision = value.GetStringValue() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // case "decision_source": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // event.DecisionSource = value.GetStringValue() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // case "decision_type": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // event.DecisionType = value.GetStringValue() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // case "tool_result_size_bytes": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // event.ToolResultSizeBytes = getIntFromValue(value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "source": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| event.Source = value.GetStringValue() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "error": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -530,6 +536,20 @@ func getIntFromValue(value *commonv1.AnyValue) int { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func getBoolFromValue(value *commonv1.AnyValue) bool { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // First try to get as bool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if boolVal := value.GetBoolValue(); boolVal { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return boolVal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Try to parse from string (Claude Code sends some values as strings) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if strVal := value.GetStringValue(); strVal != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if parsed, err := strconv.ParseBool(strVal); err == nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return parsed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+539
to
+551
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function can panic if Additionally, the current implementation is a bit difficult to follow. A type switch on
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // getFloatFromValue extracts a float64 from an OTEL value, handling both double and string formats | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func getFloatFromValue(value *commonv1.AnyValue) float64 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // First try to get as double | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commented-out code should be removed. If this functionality is planned for the future, it should be tracked in an issue rather than being left as dead code in the codebase, as it reduces readability.