Skip to content

Commit

Permalink
[APM] FIX trace waterfall loading logic to handle empty scenarios (el…
Browse files Browse the repository at this point in the history
…astic#163397)

## Summary

Closes elastic#154705

## List of Issues

- Trace Waterfall not clearing and persisting old data

![Trace Explorer Not
clearing](https://github.com/elastic/kibana/assets/7416358/5302c5ed-0c92-44ab-81a5-115e32dc8ace)

- Infinite Loading of Trace Waterfall where no traces are present and
page is reloaded

![Infinite
Loading](https://github.com/elastic/kibana/assets/7416358/c5ae1cda-099e-4968-96e5-ad85db38d83a)

- After Fixing these 2 issues, found issue with Container Height

![Container Height
Issue](https://github.com/elastic/kibana/assets/7416358/7fc7ef1b-68dc-4f52-bc2f-c346cfd5f67e)

## All issues fixed

![All issues
resolved](https://github.com/elastic/kibana/assets/7416358/227fe648-d6b9-4788-8961-7369f6ed621a)
  • Loading branch information
achyutjhunjhunwala authored and bryce-b committed Aug 9, 2023
1 parent 7de91b8 commit 1393015
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
Expand Up @@ -151,4 +151,30 @@ describe('Transaction details', () => {
});
});
});

describe('when changing filters which results in no trace samples', () => {
it('trace waterfall must reset to empty state', () => {
cy.visitKibana(
`/app/apm/services/opbeans-java/transactions/view?${new URLSearchParams(
{
...timeRange,
transactionName: 'GET /api/product',
}
)}`
);

cy.getByTestSubj('apmWaterfallButton').should('exist');

cy.getByTestSubj('apmUnifiedSearchBar')
.type(`_id: "123"`)
.type('{enter}');

cy.getByTestSubj('apmWaterfallButton').should('not.exist');
cy.getByTestSubj('apmNoTraceFound').should('exist');

cy.reload();

cy.getByTestSubj('apmNoTraceFound').should('exist');
});
});
});
Expand Up @@ -20,7 +20,7 @@ import { useApmServiceContext } from '../../../../context/apm_service/use_apm_se
import { useAnyOfApmParams } from '../../../../hooks/use_apm_params';
import { useTimeRange } from '../../../../hooks/use_time_range';
import { DurationDistributionChartWithScrubber } from '../../../shared/charts/duration_distribution_chart_with_scrubber';
import { HeightRetainer } from '../../../shared/height_retainer';
import { ResettingHeightRetainer } from '../../../shared/height_retainer/resetting_height_container';
import { fromQuery, push, toQuery } from '../../../shared/links/url_helpers';
import { TransactionTab } from '../waterfall_with_summary/transaction_tabs';
import { useTransactionDistributionChartData } from './use_transaction_distribution_chart_data';
Expand Down Expand Up @@ -99,7 +99,7 @@ export function TransactionDistribution({
);

return (
<HeightRetainer>
<ResettingHeightRetainer reset={!traceId}>
<div data-test-subj="apmTransactionDistributionTabContent">
<DurationDistributionChartWithScrubber
onChartSelection={onChartSelection}
Expand Down Expand Up @@ -138,6 +138,6 @@ export function TransactionDistribution({
onShowCriticalPathChange={onShowCriticalPathChange}
/>
</div>
</HeightRetainer>
</ResettingHeightRetainer>
);
}
Expand Up @@ -56,7 +56,10 @@ export function useWaterfallFetcher({
[traceId, start, end, transactionId]
);

const waterfall = useMemo(() => getWaterfall(data), [data]);
const waterfall = useMemo(
() => getWaterfall(traceId ? data : INITIAL_DATA),
[data, traceId]
);

return { waterfall, status, error };
}
Expand Up @@ -60,8 +60,10 @@ export function WaterfallWithSummary<TSample extends {}>({
const isLoading =
waterfallFetchResult.status === FETCH_STATUS.LOADING ||
traceSamplesFetchStatus === FETCH_STATUS.LOADING;
// When traceId is not present, call to waterfallFetchResult will not be initiated
const isSucceded =
waterfallFetchResult.status === FETCH_STATUS.SUCCESS &&
(waterfallFetchResult.status === FETCH_STATUS.SUCCESS ||
waterfallFetchResult.status === FETCH_STATUS.NOT_INITIATED) &&
traceSamplesFetchStatus === FETCH_STATUS.SUCCESS;

useEffect(() => {
Expand Down Expand Up @@ -96,6 +98,7 @@ export function WaterfallWithSummary<TSample extends {}>({
})}
</div>
}
data-test-subj="apmNoTraceFound"
titleSize="s"
/>
);
Expand Down

0 comments on commit 1393015

Please sign in to comment.