From 931b54f636896aca32cf99a58c510d2767fa4123 Mon Sep 17 00:00:00 2001 From: Oliver Gupte Date: Tue, 9 Mar 2021 12:37:11 -0800 Subject: [PATCH] [APM] Handle correlations view with missing field names (#93443) (#94015) * [APM] Handle correlations view with missing field names (#93443) * fixes spelling Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../components/app/correlations/error_correlations.tsx | 8 +++++--- .../components/app/correlations/latency_correlations.tsx | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/apm/public/components/app/correlations/error_correlations.tsx b/x-pack/plugins/apm/public/components/app/correlations/error_correlations.tsx index 4e8a8e3f5092f..c3b5f52dd84b7 100644 --- a/x-pack/plugins/apm/public/components/app/correlations/error_correlations.tsx +++ b/x-pack/plugins/apm/public/components/app/correlations/error_correlations.tsx @@ -63,10 +63,11 @@ export function ErrorCorrelations({ onClose }: Props) { `apm.correlations.errors.fields:${serviceName}`, defaultFieldNames ); + const hasFieldNames = fieldNames.length > 0; const { data, status } = useFetcher( (callApmApi) => { - if (start && end) { + if (start && end && hasFieldNames) { return callApmApi({ endpoint: 'GET /api/apm/correlations/failed_transactions', params: { @@ -93,6 +94,7 @@ export function ErrorCorrelations({ onClose }: Props) { transactionName, transactionType, fieldNames, + hasFieldNames, ] ); @@ -123,7 +125,7 @@ export function ErrorCorrelations({ onClose }: Props) { @@ -134,7 +136,7 @@ export function ErrorCorrelations({ onClose }: Props) { 'xpack.apm.correlations.error.percentageColumnName', { defaultMessage: '% of failed transactions' } )} - significantTerms={data?.significantTerms} + significantTerms={hasFieldNames ? data?.significantTerms : []} status={status} setSelectedSignificantTerm={setSelectedSignificantTerm} onFilter={onClose} diff --git a/x-pack/plugins/apm/public/components/app/correlations/latency_correlations.tsx b/x-pack/plugins/apm/public/components/app/correlations/latency_correlations.tsx index 76e9a9242efbe..77571421ed00e 100644 --- a/x-pack/plugins/apm/public/components/app/correlations/latency_correlations.tsx +++ b/x-pack/plugins/apm/public/components/app/correlations/latency_correlations.tsx @@ -61,6 +61,8 @@ export function LatencyCorrelations({ onClose }: Props) { `apm.correlations.latency.fields:${serviceName}`, defaultFieldNames ); + const hasFieldNames = fieldNames.length > 0; + const [ durationPercentile, setDurationPercentile, @@ -71,7 +73,7 @@ export function LatencyCorrelations({ onClose }: Props) { const { data, status } = useFetcher( (callApmApi) => { - if (start && end) { + if (start && end && hasFieldNames) { return callApmApi({ endpoint: 'GET /api/apm/correlations/slow_transactions', params: { @@ -100,6 +102,7 @@ export function LatencyCorrelations({ onClose }: Props) { transactionType, durationPercentile, fieldNames, + hasFieldNames, ] ); @@ -131,7 +134,7 @@ export function LatencyCorrelations({ onClose }: Props) { @@ -144,7 +147,7 @@ export function LatencyCorrelations({ onClose }: Props) { 'xpack.apm.correlations.latency.percentageColumnName', { defaultMessage: '% of slow transactions' } )} - significantTerms={data?.significantTerms} + significantTerms={hasFieldNames ? data?.significantTerms : []} status={status} setSelectedSignificantTerm={setSelectedSignificantTerm} onFilter={onClose}