Skip to content

Commit

Permalink
[Observability AI Assistant] Return errorDoc instead of error in …
Browse files Browse the repository at this point in the history
…GetApmErrorDocument function (#165588)
  • Loading branch information
CoenWarmer authored Sep 4, 2023
1 parent 4b4ba09 commit 046cfc8
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 046cfc8

Please sign in to comment.