From d7ba901c50181141cd048b1d76f01841480ad458 Mon Sep 17 00:00:00 2001 From: Oliver Gupte Date: Thu, 11 Mar 2021 09:55:12 -0800 Subject: [PATCH] [APM] Handle correlations view with missing field names (#93443) (#94015) (#94197) * [APM] Handle correlations view with missing field names (#93443) * fixes spelling Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> 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 e5e7b0c7e1738..b27beb25ecc34 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 @@ -62,10 +62,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: { @@ -92,6 +93,7 @@ export function ErrorCorrelations({ onClose }: Props) { transactionType, uiFilters, fieldNames, + hasFieldNames, ] ); @@ -122,7 +124,7 @@ export function ErrorCorrelations({ onClose }: Props) { @@ -133,7 +135,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 dd77b7266a387..da3bd109d5dc6 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 @@ -60,6 +60,8 @@ export function LatencyCorrelations({ onClose }: Props) { `apm.correlations.latency.fields:${serviceName}`, defaultFieldNames ); + const hasFieldNames = fieldNames.length > 0; + const [ durationPercentile, setDurationPercentile, @@ -70,7 +72,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: { @@ -99,6 +101,7 @@ export function LatencyCorrelations({ onClose }: Props) { uiFilters, durationPercentile, fieldNames, + hasFieldNames, ] ); @@ -130,7 +133,7 @@ export function LatencyCorrelations({ onClose }: Props) { @@ -143,7 +146,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}