Skip to content

Commit

Permalink
addressing pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Oct 19, 2020
1 parent d4515ed commit 0022636
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions x-pack/plugins/apm/server/lib/helpers/transaction_error_rate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ export function calculateTransactionErrorPercentage(
{}
>
) {
const successfulTransactions =
outcomeResponse.buckets.find(
(bucket) => bucket.key === EventOutcome.success
)?.count.value ?? 0;
const outcomes = Object.fromEntries(
outcomeResponse.buckets.map(({ key, count }) => [key, count.value])
);

const failedTransactions =
outcomeResponse.buckets.find(
(bucket) => bucket.key === EventOutcome.failure
)?.count.value ?? 0;
const failedTransactions = outcomes[EventOutcome.failure] ?? 0;
const successfulTransactions = outcomes[EventOutcome.success] ?? 0;

return failedTransactions / (successfulTransactions + failedTransactions);
}
Expand Down

0 comments on commit 0022636

Please sign in to comment.