Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance task failure log to include error source in tags (elastic#199406
) Resolves elastic#199346 In this PR I'm adding `user-error` and `framework-error` tags to the associated task failure logs. ## To verify You can either use the jest test to observe the returned flags or set your logging to JSON and use the following code samples to test various types of errors. kibana.yml to set logging to JSON ``` logging: appenders: json-layout: type: console layout: type: json root: appenders: [json-layout] ``` Code samples throwing various types of errors. ``` diff --git a/x-pack/plugins/alerting/server/task_runner/task_runner.ts b/x-pack/plugins/alerting/server/task_runner/task_runner.ts index 89432e18220..129b53f71b4 100644 --- a/x-pack/plugins/alerting/server/task_runner/task_runner.ts +++ b/x-pack/plugins/alerting/server/task_runner/task_runner.ts @@ -649,6 +649,10 @@ export class TaskRunner< schedule: taskSchedule, } = this.taskInstance; + // throw createTaskRunError(new Error('foo'), TaskErrorSource.USER); + // throw createTaskRunError(new Error('foo'), TaskErrorSource.FRAMEWORK); + // throw new Error('foo'); + this.logger = createTaskRunnerLogger({ logger: this.logger, tags: [ruleId, this.ruleType.id] }); let stateWithMetrics: Result<RuleTaskStateAndMetrics, Error>; ```
- Loading branch information