Skip to content

Commit

Permalink
Set ruleType thrown errors as Framework error (elastic#179656)
Browse files Browse the repository at this point in the history
This is a follow-on PR of
elastic#174035.

As we decided to set the errors reported by addLastRunError as Framework
Error, this PR aligns the other errors thrown by the ruleTypes by
switching from USER to FRAMEWORK.

## To verify

Throw an error in any of the ruleType executor, and expect to see
framework error metrics in :
`/api/task_manager/metrics?reset=false`
  • Loading branch information
ersin-erdal authored Mar 29, 2024
1 parent d970560 commit 531dd0f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export class RuleTypeRunner<
return {
error: createTaskRunError(
new ErrorWithReason(RuleExecutionStatusErrorReasons.Execute, err),
TaskErrorSource.USER
TaskErrorSource.FRAMEWORK
),
stackTrace: { message: err, stackTrace: err.stack },
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ describe('Task Runner', () => {
expect(loggerMeta?.tags).toEqual(['test', '1', 'rule-run-failed']);
expect(loggerMeta?.error?.stack_trace).toBeDefined();
expect(logger.error).toBeCalledTimes(1);
expect(getErrorSource(runnerResult.taskRunError as Error)).toBe(TaskErrorSource.USER);
expect(getErrorSource(runnerResult.taskRunError as Error)).toBe(TaskErrorSource.FRAMEWORK);
});

test('recovers gracefully when the Rule Task Runner throws an exception when loading rule to prepare for run', async () => {
Expand Down

0 comments on commit 531dd0f

Please sign in to comment.