import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey' ; import type { ElasticsearchClient } from 'src/core/server' ; import type { FieldValuePair , CorrelationsParams , } from '../../../../common/correlations/types' ; import type { LatencyCorrelation } from '../../../../common/correlations/latency_correlations/types' ; import { CORRELATION_THRESHOLD , KS_TEST_THRESHOLD , } from '../../../../common/correlations/constants' ; import { fetchTransactionDurationCorrelation } from './query_correlation' ; import { fetchTransactionDurationRanges } from './query_ranges' ; export async function fetchTransactionDurationCorrelationWithHistogram ( esClient , params , expectations , ranges , fractions , histogramRangeSteps , totalDocCount , fieldValuePair ) { const { correlation , ksTest } = await fetchTransactionDurationCorrelation ( esClient , params , expectations , ranges , fractions , totalDocCount , [ fieldValuePair ] ) ; if ( correlation !== null && correlation > CORRELATION_THRESHOLD && ksTest !== null && ksTest < KS_TEST_THRESHOLD ) { const logHistogram = await fetchTransactionDurationRanges ( esClient , params , histogramRangeSteps , [ fieldValuePair ] ) ; return { ... fieldValuePair , correlation , ksTest , histogram : logHistogram , } ; } }