Enhance task failure log to include error source in tags#199406
Enhance task failure log to include error source in tags#199406mikecote merged 3 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/response-ops (Team:ResponseOps) |
pmuellr
left a comment
There was a problem hiding this comment.
LGTM
Though I'm a little surprised some existing tests didn't fail. I guess we didn't have any testing exhaustive tags on these messages, that would be failing with a new framework-error tag in them (the default).
💔 Build Failed
Failed CI StepsHistory
cc @mikecote |
💚 Build Succeeded
Metrics [docs]
History
cc @mikecote |
The tests I updated were to only ones covering the error thrown during task run phase. Everything else seemed to cover the happy paths. |
|
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/11824702329 |
) 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 89432e1..129b53f 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>; ``` (cherry picked from commit 544525d)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…) (#200082) # Backport This will backport the following commits from `main` to `8.x`: - [Enhance task failure log to include error source in tags (#199406)](#199406) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Mike Côté","email":"mikecote@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-11-13T19:48:18Z","message":"Enhance task failure log to include error source in tags (#199406)\n\nResolves https://github.com/elastic/kibana/issues/199346\r\n\r\nIn this PR I'm adding `user-error` and `framework-error` tags to the\r\nassociated task failure logs.\r\n\r\n## To verify\r\n\r\nYou can either use the jest test to observe the returned flags or set\r\nyour logging to JSON and use the following code samples to test various\r\ntypes of errors.\r\n\r\nkibana.yml to set logging to JSON\r\n```\r\nlogging:\r\n appenders:\r\n json-layout:\r\n type: console\r\n layout:\r\n type: json\r\n root:\r\n appenders: [json-layout]\r\n```\r\n\r\nCode samples throwing various types of errors.\r\n```\r\ndiff --git a/x-pack/plugins/alerting/server/task_runner/task_runner.ts b/x-pack/plugins/alerting/server/task_runner/task_runner.ts\r\nindex 89432e1..129b53f 100644\r\n--- a/x-pack/plugins/alerting/server/task_runner/task_runner.ts\r\n+++ b/x-pack/plugins/alerting/server/task_runner/task_runner.ts\r\n@@ -649,6 +649,10 @@ export class TaskRunner<\r\n schedule: taskSchedule,\r\n } = this.taskInstance;\r\n\r\n+ // throw createTaskRunError(new Error('foo'), TaskErrorSource.USER);\r\n+ // throw createTaskRunError(new Error('foo'), TaskErrorSource.FRAMEWORK);\r\n+ // throw new Error('foo');\r\n+\r\n this.logger = createTaskRunnerLogger({ logger: this.logger, tags: [ruleId, this.ruleType.id] });\r\n\r\n let stateWithMetrics: Result<RuleTaskStateAndMetrics, Error>;\r\n```","sha":"544525d497d6c833c9a861061876412d3198c5e9","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Feature:Task Manager","Team:ResponseOps","v9.0.0","backport:version","v8.17.0"],"title":"Enhance task failure log to include error source in tags","number":199406,"url":"https://github.com/elastic/kibana/pull/199406","mergeCommit":{"message":"Enhance task failure log to include error source in tags (#199406)\n\nResolves https://github.com/elastic/kibana/issues/199346\r\n\r\nIn this PR I'm adding `user-error` and `framework-error` tags to the\r\nassociated task failure logs.\r\n\r\n## To verify\r\n\r\nYou can either use the jest test to observe the returned flags or set\r\nyour logging to JSON and use the following code samples to test various\r\ntypes of errors.\r\n\r\nkibana.yml to set logging to JSON\r\n```\r\nlogging:\r\n appenders:\r\n json-layout:\r\n type: console\r\n layout:\r\n type: json\r\n root:\r\n appenders: [json-layout]\r\n```\r\n\r\nCode samples throwing various types of errors.\r\n```\r\ndiff --git a/x-pack/plugins/alerting/server/task_runner/task_runner.ts b/x-pack/plugins/alerting/server/task_runner/task_runner.ts\r\nindex 89432e1..129b53f 100644\r\n--- a/x-pack/plugins/alerting/server/task_runner/task_runner.ts\r\n+++ b/x-pack/plugins/alerting/server/task_runner/task_runner.ts\r\n@@ -649,6 +649,10 @@ export class TaskRunner<\r\n schedule: taskSchedule,\r\n } = this.taskInstance;\r\n\r\n+ // throw createTaskRunError(new Error('foo'), TaskErrorSource.USER);\r\n+ // throw createTaskRunError(new Error('foo'), TaskErrorSource.FRAMEWORK);\r\n+ // throw new Error('foo');\r\n+\r\n this.logger = createTaskRunnerLogger({ logger: this.logger, tags: [ruleId, this.ruleType.id] });\r\n\r\n let stateWithMetrics: Result<RuleTaskStateAndMetrics, Error>;\r\n```","sha":"544525d497d6c833c9a861061876412d3198c5e9"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/199406","number":199406,"mergeCommit":{"message":"Enhance task failure log to include error source in tags (#199406)\n\nResolves https://github.com/elastic/kibana/issues/199346\r\n\r\nIn this PR I'm adding `user-error` and `framework-error` tags to the\r\nassociated task failure logs.\r\n\r\n## To verify\r\n\r\nYou can either use the jest test to observe the returned flags or set\r\nyour logging to JSON and use the following code samples to test various\r\ntypes of errors.\r\n\r\nkibana.yml to set logging to JSON\r\n```\r\nlogging:\r\n appenders:\r\n json-layout:\r\n type: console\r\n layout:\r\n type: json\r\n root:\r\n appenders: [json-layout]\r\n```\r\n\r\nCode samples throwing various types of errors.\r\n```\r\ndiff --git a/x-pack/plugins/alerting/server/task_runner/task_runner.ts b/x-pack/plugins/alerting/server/task_runner/task_runner.ts\r\nindex 89432e1..129b53f 100644\r\n--- a/x-pack/plugins/alerting/server/task_runner/task_runner.ts\r\n+++ b/x-pack/plugins/alerting/server/task_runner/task_runner.ts\r\n@@ -649,6 +649,10 @@ export class TaskRunner<\r\n schedule: taskSchedule,\r\n } = this.taskInstance;\r\n\r\n+ // throw createTaskRunError(new Error('foo'), TaskErrorSource.USER);\r\n+ // throw createTaskRunError(new Error('foo'), TaskErrorSource.FRAMEWORK);\r\n+ // throw new Error('foo');\r\n+\r\n this.logger = createTaskRunnerLogger({ logger: this.logger, tags: [ruleId, this.ruleType.id] });\r\n\r\n let stateWithMetrics: Result<RuleTaskStateAndMetrics, Error>;\r\n```","sha":"544525d497d6c833c9a861061876412d3198c5e9"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Mike Côté <mikecote@users.noreply.github.com>
) 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 89432e1..129b53f 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>; ```
) 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 89432e1..129b53f 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>; ```
Resolves #199346
In this PR I'm adding
user-errorandframework-errortags 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
Code samples throwing various types of errors.