forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] Error rate on service list page is not in sync with the value a…
…t the transaction page (elastic#80814) (elastic#81148) * fixing error rate * addressing pr comments * addressing pr comments * fixing TS issue * fixing api test
- Loading branch information
1 parent
530c2ec
commit 6b29f9f
Showing
6 changed files
with
117 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
x-pack/plugins/apm/server/lib/helpers/transaction_error_rate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { EVENT_OUTCOME } from '../../../common/elasticsearch_fieldnames'; | ||
import { EventOutcome } from '../../../common/event_outcome'; | ||
import { | ||
AggregationOptionsByType, | ||
AggregationResultOf, | ||
} from '../../../typings/elasticsearch/aggregations'; | ||
import { getTransactionDurationFieldForAggregatedTransactions } from './aggregated_transactions'; | ||
|
||
export function getOutcomeAggregation({ | ||
searchAggregatedTransactions, | ||
}: { | ||
searchAggregatedTransactions: boolean; | ||
}) { | ||
return { | ||
terms: { field: EVENT_OUTCOME }, | ||
aggs: { | ||
count: { | ||
value_count: { | ||
field: getTransactionDurationFieldForAggregatedTransactions( | ||
searchAggregatedTransactions | ||
), | ||
}, | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
export function calculateTransactionErrorPercentage( | ||
outcomeResponse: AggregationResultOf< | ||
ReturnType<typeof getOutcomeAggregation>, | ||
{} | ||
> | ||
) { | ||
const outcomes = Object.fromEntries( | ||
outcomeResponse.buckets.map(({ key, count }) => [key, count.value]) | ||
); | ||
|
||
const failedTransactions = outcomes[EventOutcome.failure] ?? 0; | ||
const successfulTransactions = outcomes[EventOutcome.success] ?? 0; | ||
|
||
return failedTransactions / (successfulTransactions + failedTransactions); | ||
} | ||
|
||
export function getTransactionErrorRateTimeSeries( | ||
buckets: AggregationResultOf< | ||
{ | ||
date_histogram: AggregationOptionsByType['date_histogram']; | ||
aggs: { outcomes: ReturnType<typeof getOutcomeAggregation> }; | ||
}, | ||
{} | ||
>['buckets'] | ||
) { | ||
return buckets.map((dateBucket) => { | ||
return { | ||
x: dateBucket.key, | ||
y: calculateTransactionErrorPercentage(dateBucket.outcomes), | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters