-
Notifications
You must be signed in to change notification settings - Fork 0
Djt/0111/spanname #26
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -143,7 +143,11 @@ func (manager *Manager) Run(ctx context.Context) error { | |||||||||
| // Run task loop with handler (if any queues registered) | ||||||||||
| if len(queues) > 0 { | ||||||||||
| if err := manager.RunTaskLoop(ctx, func(ctx context.Context, task *schema.Task) error { | ||||||||||
| return manager.runTaskWorker(ctx, task, manager.tracer) | ||||||||||
| err := manager.runTaskWorker(ctx, task, manager.tracer) | ||||||||||
| if err != nil { | ||||||||||
| log.With("task", task).Print(ctx, err) | ||||||||||
| } | ||||||||||
| return err | ||||||||||
| }, queues...); err != nil { | ||||||||||
| if !errors.Is(err, context.Canceled) { | ||||||||||
| mu.Lock() | ||||||||||
|
|
@@ -206,13 +210,12 @@ func (manager *Manager) runTaskWorker(ctx context.Context, task *schema.Task, tr | |||||||||
| return fmt.Errorf("no worker registered for queue %q", task.Queue) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| var result error | ||||||||||
|
|
||||||||||
| // Set deadline based on task dies_at | ||||||||||
| child, cancel := withDeadline(ctx, types.PtrTime(task.DiesAt)) | ||||||||||
| defer cancel() | ||||||||||
|
|
||||||||||
| // Create the span | ||||||||||
| var result error | ||||||||||
| child2, endfunc := otel.StartSpan(tracer, child, spanManagerName("task."+task.Queue), | ||||||||||
| attribute.String("task", task.String()), | ||||||||||
| ) | ||||||||||
|
|
@@ -222,10 +225,17 @@ func (manager *Manager) runTaskWorker(ctx context.Context, task *schema.Task, tr | |||||||||
| result = worker.Run(child2, task.Payload) | ||||||||||
|
|
||||||||||
| // Release the task back to the queue as success/failure (use child2 to nest the span) | ||||||||||
| if _, releaseErr := manager.ReleaseTask(child2, task.Id, result == nil, result, nil); releaseErr != nil { | ||||||||||
| var status string | ||||||||||
| if _, releaseErr := manager.ReleaseTask(child2, task.Id, result == nil, result, &status); releaseErr != nil { | ||||||||||
| result = errors.Join(result, releaseErr) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // If the status is not 'released', log a warning | ||||||||||
|
||||||||||
| // If the status is not 'released', log a warning | |
| // If the status is not 'released', record this in the result error |
Copilot
AI
Jan 13, 2026
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 logic incorrectly treats all non-"released" statuses as errors. According to the database schema, valid task statuses include 'expired', 'new', 'failed', 'retry', 'retained', 'released', and 'unknown'. Status 'retry' is a valid outcome when a task is being retried and should not be treated as an error. Consider checking for explicitly problematic statuses (e.g., 'failed', 'expired') rather than checking for the absence of 'released'.
| // If the status is not 'released', log a warning | |
| if status != "released" { | |
| // Only treat explicitly problematic statuses as errors | |
| if status == "failed" || status == "expired" || status == "unknown" { |
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 log variable may be nil, which would cause a panic when calling log.With. Add a nil check before using the logger, similar to the pattern used elsewhere in this file (see lines 106-111).