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 Sep 12, 2024
1 parent 3f39469 commit b5dcc0d
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 b5dcc0d

Please sign in to comment.