-
Notifications
You must be signed in to change notification settings - Fork 0
fix(daemon): include debug context in OTEL metrics log #246
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -80,7 +80,7 @@ func (p *AICodeOtelProcessor) writeDebugFile(filename string, data interface{}) | |||||
|
|
||||||
| // ProcessMetrics receives OTEL metrics and forwards to backend immediately | ||||||
| func (p *AICodeOtelProcessor) ProcessMetrics(ctx context.Context, req *collmetricsv1.ExportMetricsServiceRequest) (*collmetricsv1.ExportMetricsServiceResponse, error) { | ||||||
| slog.Debug("AICodeOtel: Processing metrics request", "resourceMetricsCount", len(req.GetResourceMetrics())) | ||||||
| slog.Debug("AICodeOtel: Processing metrics request", "resourceMetricsCount", slog.Int("len", len(req.GetResourceMetrics())), slog.Bool("debug", p.debug)) | ||||||
|
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. 🟡 Mixing slog string key with slog.Attr value produces malformed log attribute On line 83, Root Cause and comparison with ProcessLogsThe slog.Debug("...", "resourceMetricsCount", slog.Int("len", len(req.GetResourceMetrics())), slog.Bool("debug", p.debug))
Compare with the correct pattern on slog.Debug("...", "resourceLogsCount", len(req.GetResourceLogs()), slog.Bool("debug", p.debug))Here the value for Impact: The metrics count log attribute will have a misleading nested key name (
Suggested change
Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||
|
|
||||||
| if p.debug { | ||||||
| p.writeDebugFile("aicode-otel-debug-metrics.txt", req) | ||||||
|
|
||||||
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.
The current usage of
slog.Debugis incorrect and will result in a malformed log entry with a!BADKEYattribute. Theslog.Boolattribute is not preceded by a string key, which causesslogto report an error in the log output. To fix this and create the intended nested structure forresourceMetricsCountwhile also including thedebugflag, you should useslog.Group.