Skip to content

Commit

Permalink
[8.10] [Observability AI Assistant] Return errorDoc instead of `err…
Browse files Browse the repository at this point in the history
…or` in GetApmErrorDocument function (#165588) (#165601)

# Backport

This will backport the following commits from `main` to `8.10`:
- [[Observability AI Assistant] Return `errorDoc` instead of `error` in
GetApmErrorDocument function
(#165588)](#165588)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Coen
Warmer","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-09-04T13:49:48Z","message":"[Observability
AI Assistant] Return `errorDoc` instead of `error` in
GetApmErrorDocument function
(#165588)","sha":"046cfc854dfbcf946d775c8f204b0a2c74414cd6","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:APM","release_note:skip","backport:prev-minor","v8.10.0","v8.11.0"],"number":165588,"url":"https://github.com/elastic/kibana/pull/165588","mergeCommit":{"message":"[Observability
AI Assistant] Return `errorDoc` instead of `error` in
GetApmErrorDocument function
(#165588)","sha":"046cfc854dfbcf946d775c8f204b0a2c74414cd6"}},"sourceBranch":"main","suggestedTargetBranches":["8.10"],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/165588","number":165588,"mergeCommit":{"message":"[Observability
AI Assistant] Return `errorDoc` instead of `error` in
GetApmErrorDocument function
(#165588)","sha":"046cfc854dfbcf946d775c8f204b0a2c74414cd6"}}]}]
BACKPORT-->

Co-authored-by: Coen Warmer <[email protected]>
  • Loading branch information
kibanamachine and CoenWarmer authored Sep 4, 2023
1 parent 18cfd84 commit 0e0846a
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export async function getApmErrorDocument({
},
});

const error = response.hits.hits[0]?._source as APMError;
const errorDoc = response.hits.hits[0]?._source as APMError;

if (!error) {
if (!errorDoc) {
return undefined;
}

return pick(
error,
const formattedResponse = pick(
errorDoc,
'message',
'error',
'@timestamp',
Expand All @@ -71,4 +71,11 @@ export async function getApmErrorDocument({
'span.type',
'span.subtype'
);

const { error, ...rest } = formattedResponse;

return {
...rest,
errorDoc: formattedResponse.error,
};
}

0 comments on commit 0e0846a

Please sign in to comment.