import { ProcessorEvent } from '../../../common/processor_event' ; import { getTransactionDurationPercentilesRequest } from '../correlations/queries/query_percentiles' ; import type { OverallLatencyDistributionOptions } from './types' ; export async function getPercentileThresholdValue ( options ) { const { setup , percentileThreshold , ... rawParams } = options ; const { apmEventClient } = setup ; const params = { index : '' , ... rawParams , } ; const { body : transactionDurationPercentilesRequestBody } = getTransactionDurationPercentilesRequest ( params , [ percentileThreshold ] ) ; const transactionDurationPercentilesResponse = ( await apmEventClient . search ( 'get_transaction_duration_percentiles' , { apm : { events : [ ProcessorEvent . transaction ] } , body : transactionDurationPercentilesRequestBody , } ) ) as { aggregations ? : { transaction_duration_percentiles : { values : Record < string , number > ; } ; } ; } ; if ( ! transactionDurationPercentilesResponse . aggregations ) { return ; } const percentilesResponseThresholds = transactionDurationPercentilesResponse . aggregations . transaction_duration_percentiles ?. values ?? { } ; return percentilesResponseThresholds [ `${ percentileThreshold }.0` ] ; }