Skip to content

Commit

Permalink
Fix overdue tasks metric to consider retryAt when the task status isn…
Browse files Browse the repository at this point in the history
…'t idle (elastic#192603)

In this PR, I'm fixing the runtime field used to calculate the number of
overdue tasks so it considers `retryAt` field when tasks are in running
or claiming status.
  • Loading branch information
mikecote authored and gergoabraham committed Sep 13, 2024
1 parent 4297d1a commit ed68d72
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,15 @@ describe('TaskManagerMetricsCollector', () => {
type: 'long',
script: {
source: `
def taskStatus = doc['task.status'];
def runAt = doc['task.runAt'];
if(!runAt.empty) {
if (taskStatus.empty) {
emit(0);
return;
}
if(taskStatus == 'idle') {
emit((new Date().getTime() - runAt.value.getMillis()) / 1000);
} else {
def retryAt = doc['task.retryAt'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,15 @@ export class TaskManagerMetricsCollector implements ITaskEventEmitter<TaskLifecy
type: 'long',
script: {
source: `
def taskStatus = doc['task.status'];
def runAt = doc['task.runAt'];
if(!runAt.empty) {
if (taskStatus.empty) {
emit(0);
return;
}
if(taskStatus == 'idle') {
emit((new Date().getTime() - runAt.value.getMillis()) / 1000);
} else {
def retryAt = doc['task.retryAt'];
Expand Down

0 comments on commit ed68d72

Please sign in to comment.