-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Profiling] Adding normalize by time and scale factor on Diff TopN fu…
…nctions page (#159394) Relevant changes: - Adding **Normalize by** field on the Diff TopN functions page. - Refactoring functions route/pages. <img width="1469" alt="Screenshot 2023-06-09 at 2 34 48 PM" src="https://github.com/elastic/kibana/assets/55978943/b2c824bd-94ff-4f8b-a6b2-b9c30c51881e"> <img width="1353" alt="Screenshot 2023-06-09 at 2 34 58 PM" src="https://github.com/elastic/kibana/assets/55978943/9d1de932-8669-4ddf-968a-057199211931"> --------- Co-authored-by: kibanamachine <[email protected]>
- v8.17.0
- v8.16.2
- v8.16.1
- v8.16.0
- v8.15.5
- v8.15.4
- v8.15.3
- v8.15.2
- v8.15.1
- v8.15.0
- v8.14.3
- v8.14.2
- v8.14.1
- v8.14.0
- v8.13.4
- v8.13.3
- v8.13.2
- v8.13.1
- v8.13.0
- v8.12.2
- v8.12.1
- v8.12.0
- v8.11.4
- v8.11.3
- v8.11.2
- v8.11.1
- v8.11.0
- v8.10.4
- v8.10.3
- v8.10.2
- v8.10.1
- v8.10.0
- v8.9.2
- v8.9.1
- v8.9.0
- test-depl-20231025084603
- test-depl-20231013154558
- deploy-fix-test-ci
- deploy-fix@1728886420
- deploy-fix@1722233551
- deploy-fix@1721023892
- deploy-fix@1720419201
- deploy-fix@1718000036
- deploy-fix@1717401777
- deploy-fix@1708322739
- deploy-fix@1707717945
- deploy-fix@1701687168
- deploy-fix@1699260155
- deploy-fix@1698657637
- deploy@1736144018
- deploy@1735539127
- deploy@1734934371
- deploy@1734329529
- deploy@1733724770
- deploy@1733120035
- deploy@1732515196
- deploy@1731910526
- deploy@1731305644
- deploy@1730700921
- deploy@1730095989
- deploy@1729491328
- deploy@1728886420
- deploy@1728281754
- deploy@1727676838
- deploy@1727071987
- deploy@1726473511
- deploy@1725862301
- deploy@1725257503
- deploy@1724652827
- deploy@1724047965
- deploy@1723443177
- deploy@1722838314
- deploy@1722233551
- deploy@1721628835
- deploy@1721023892
- deploy@1720419201
- deploy@1719814351
- deploy@1719209622
- deploy@1718616070
- deploy@1718000036
- deploy@1717401777
- deploy@1717395230
- deploy@1716800745
- deploy@1716790412
- deploy@1716185667
- deploy@1715580861
- deploy@1714976069
- deploy@1714371303
- deploy@1713766425
- deploy@1713161715
- deploy@1712566963
- deploy@1711952105
- deploy@1711370131
- deploy@1710741924
- deploy@1710146776
- deploy@1710137117
- deploy@1709533819
- deploy@1709532332
- deploy@1708927574
- deploy@1708322739
- deploy@1707717945
- deploy@1707113127
- deploy@1706508321
- deploy@1705903520
- deploy@1705306975
- deploy@1705298718
- deploy@1704693922
- deploy@1704089101
- deploy@1703484304
- deploy@1702903357
- deploy@1702879551
- deploy@1702367069
- deploy@1702284899
- deploy@1701687168
- deploy@1701160888
- deploy@1700491293
- deploy@1699865290
- deploy@1699260155
- deploy@1698657637
- deploy@1698046713
- deploy@1697564183
- deploy@1697232175
- deploy@1697028216
- deploy@1696873111
- deploy@1696618725
- deploy@1696508231
- deploy@1696415195
- deploy@1696328885
- deploy@1695286747
- deploy@1694683198
- deploy@1694506029
- deploy@1694162455
- deploy@1694087994
- deploy@1693866333
- deploy@1693860790
- deploy@1693853982
- deploy@1693609987
- deploy@1693594780
1 parent
b85d92c
commit c6bca36
Showing
16 changed files
with
524 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
208 changes: 208 additions & 0 deletions
208
x-pack/plugins/profiling/public/views/functions/differential_topn/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
import { TypeOf } from '@kbn/typed-react-router-config'; | ||
import React from 'react'; | ||
import { AsyncComponent } from '../../../components/async_component'; | ||
import { useProfilingDependencies } from '../../../components/contexts/profiling_dependencies/use_profiling_dependencies'; | ||
import { | ||
NormalizationMenu, | ||
NormalizationMode, | ||
NormalizationOptions, | ||
} from '../../../components/normalization_menu'; | ||
import { PrimaryAndComparisonSearchBar } from '../../../components/primary_and_comparison_search_bar'; | ||
import { TopNFunctionsTable } from '../../../components/topn_functions'; | ||
import { useProfilingParams } from '../../../hooks/use_profiling_params'; | ||
import { useProfilingRouter } from '../../../hooks/use_profiling_router'; | ||
import { useProfilingRoutePath } from '../../../hooks/use_profiling_route_path'; | ||
import { useTimeRange } from '../../../hooks/use_time_range'; | ||
import { useTimeRangeAsync } from '../../../hooks/use_time_range_async'; | ||
import { ProfilingRoutes } from '../../../routing'; | ||
|
||
export function DifferentialTopNFunctionsView() { | ||
const { | ||
path, | ||
query, | ||
query: { | ||
rangeFrom, | ||
rangeTo, | ||
kuery, | ||
sortDirection, | ||
sortField, | ||
comparisonKuery, | ||
normalizationMode, | ||
comparisonRangeFrom, | ||
comparisonRangeTo, | ||
baseline = 1, | ||
comparison = 1, | ||
}, | ||
} = useProfilingParams('/functions/differential'); | ||
|
||
const timeRange = useTimeRange({ rangeFrom, rangeTo }); | ||
const comparisonTimeRange = useTimeRange({ | ||
rangeFrom: comparisonRangeFrom, | ||
rangeTo: comparisonRangeTo, | ||
optional: true, | ||
}); | ||
|
||
const totalSeconds = timeRange.inSeconds.end - timeRange.inSeconds.start; | ||
const totalComparisonSeconds = | ||
(new Date(comparisonTimeRange.end!).getTime() - | ||
new Date(comparisonTimeRange.start!).getTime()) / | ||
1000; | ||
|
||
const comparisonTime = totalSeconds / totalComparisonSeconds; | ||
|
||
const baselineTime = 1; | ||
const normalizationOptions: NormalizationOptions = { | ||
baselineScale: baseline, | ||
baselineTime, | ||
comparisonScale: comparison, | ||
comparisonTime, | ||
}; | ||
|
||
const { | ||
services: { fetchTopNFunctions }, | ||
} = useProfilingDependencies(); | ||
|
||
const state = useTimeRangeAsync( | ||
({ http }) => { | ||
return fetchTopNFunctions({ | ||
http, | ||
timeFrom: timeRange.inSeconds.start, | ||
timeTo: timeRange.inSeconds.end, | ||
startIndex: 0, | ||
endIndex: 100000, | ||
kuery, | ||
}); | ||
}, | ||
[timeRange.inSeconds.start, timeRange.inSeconds.end, kuery, fetchTopNFunctions] | ||
); | ||
|
||
const comparisonState = useTimeRangeAsync( | ||
({ http }) => { | ||
if (!comparisonTimeRange.inSeconds.start || !comparisonTimeRange.inSeconds.end) { | ||
return undefined; | ||
} | ||
return fetchTopNFunctions({ | ||
http, | ||
timeFrom: comparisonTimeRange.inSeconds.start, | ||
timeTo: comparisonTimeRange.inSeconds.end, | ||
startIndex: 0, | ||
endIndex: 100000, | ||
kuery: comparisonKuery, | ||
}); | ||
}, | ||
[ | ||
comparisonTimeRange.inSeconds.start, | ||
comparisonTimeRange.inSeconds.end, | ||
comparisonKuery, | ||
fetchTopNFunctions, | ||
] | ||
); | ||
|
||
const routePath = useProfilingRoutePath() as | ||
| '/functions' | ||
| '/functions/topn' | ||
| '/functions/differential'; | ||
|
||
const profilingRouter = useProfilingRouter(); | ||
|
||
function onChangeNormalizationMode( | ||
nextNormalizationMode: NormalizationMode, | ||
options: NormalizationOptions | ||
) { | ||
profilingRouter.push(routePath, { | ||
path: routePath, | ||
query: | ||
nextNormalizationMode === NormalizationMode.Scale | ||
? { | ||
...query, | ||
baseline: options.baselineScale, | ||
comparison: options.comparisonScale, | ||
normalizationMode: nextNormalizationMode, | ||
} | ||
: { | ||
...query, | ||
normalizationMode: nextNormalizationMode, | ||
}, | ||
}); | ||
} | ||
|
||
const isNormalizedByTime = normalizationMode === NormalizationMode.Time; | ||
|
||
return ( | ||
<> | ||
<EuiFlexGroup direction="column"> | ||
<EuiFlexItem grow={false}> | ||
<PrimaryAndComparisonSearchBar /> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<NormalizationMenu | ||
mode={normalizationMode} | ||
options={normalizationOptions} | ||
onChange={onChangeNormalizationMode} | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiFlexGroup direction="row" gutterSize="s"> | ||
<EuiFlexItem> | ||
<AsyncComponent {...state} size="xl" alignTop> | ||
<TopNFunctionsTable | ||
topNFunctions={state.data} | ||
sortDirection={sortDirection} | ||
sortField={sortField} | ||
onSortChange={(nextSort) => { | ||
profilingRouter.push(routePath, { | ||
path, | ||
query: { | ||
...query, | ||
sortField: nextSort.sortField, | ||
sortDirection: nextSort.sortDirection, | ||
}, | ||
}); | ||
}} | ||
totalSeconds={timeRange.inSeconds.end - timeRange.inSeconds.start} | ||
isDifferentialView={true} | ||
baselineScaleFactor={isNormalizedByTime ? baselineTime : baseline} | ||
/> | ||
</AsyncComponent> | ||
</EuiFlexItem> | ||
{comparisonTimeRange.inSeconds.start && comparisonTimeRange.inSeconds.end ? ( | ||
<EuiFlexItem> | ||
<AsyncComponent {...comparisonState} size="xl" alignTop> | ||
<TopNFunctionsTable | ||
sortDirection={sortDirection} | ||
sortField={sortField} | ||
onSortChange={(nextSort) => { | ||
profilingRouter.push(routePath, { | ||
path, | ||
query: { | ||
...(query as TypeOf<ProfilingRoutes, '/functions/differential'>['query']), | ||
sortField: nextSort.sortField, | ||
sortDirection: nextSort.sortDirection, | ||
}, | ||
}); | ||
}} | ||
topNFunctions={comparisonState.data} | ||
comparisonTopNFunctions={state.data} | ||
totalSeconds={ | ||
comparisonTimeRange.inSeconds.end - comparisonTimeRange.inSeconds.start | ||
} | ||
isDifferentialView={true} | ||
baselineScaleFactor={isNormalizedByTime ? comparisonTime : comparison} | ||
comparisonScaleFactor={isNormalizedByTime ? baselineTime : baseline} | ||
/> | ||
</AsyncComponent> | ||
</EuiFlexItem> | ||
) : null} | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { EuiPageHeaderContentProps } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import React from 'react'; | ||
import { NormalizationMode } from '../../components/normalization_menu'; | ||
import { ProfilingAppPageTemplate } from '../../components/profiling_app_page_template'; | ||
import { RedirectTo } from '../../components/redirect_to'; | ||
import { useProfilingParams } from '../../hooks/use_profiling_params'; | ||
import { useProfilingRouter } from '../../hooks/use_profiling_router'; | ||
import { useProfilingRoutePath } from '../../hooks/use_profiling_route_path'; | ||
|
||
export function FunctionsView({ children }: { children: React.ReactElement }) { | ||
const { query } = useProfilingParams('/functions/*'); | ||
const routePath = useProfilingRoutePath() as | ||
| '/functions' | ||
| '/functions/topn' | ||
| '/functions/differential'; | ||
|
||
const profilingRouter = useProfilingRouter(); | ||
|
||
if (routePath === '/functions') { | ||
return <RedirectTo pathname="/functions/topn" />; | ||
} | ||
|
||
const isDifferentialView = routePath === '/functions/differential'; | ||
|
||
const tabs: Required<EuiPageHeaderContentProps>['tabs'] = [ | ||
{ | ||
label: i18n.translate('xpack.profiling.functionsView.functionsTabLabel', { | ||
defaultMessage: 'TopN functions', | ||
}), | ||
isSelected: !isDifferentialView, | ||
href: profilingRouter.link('/functions/topn', { query }), | ||
}, | ||
{ | ||
label: i18n.translate('xpack.profiling.functionsView.differentialFunctionsTabLabel', { | ||
defaultMessage: 'Differential TopN functions', | ||
}), | ||
isSelected: isDifferentialView, | ||
href: profilingRouter.link('/functions/differential', { | ||
query: { | ||
...query, | ||
comparisonRangeFrom: query.rangeFrom, | ||
comparisonRangeTo: query.rangeTo, | ||
comparisonKuery: query.kuery, | ||
normalizationMode: | ||
'normalizationMode' in query ? query.normalizationMode : NormalizationMode.Time, | ||
}, | ||
}), | ||
}, | ||
]; | ||
|
||
return ( | ||
<ProfilingAppPageTemplate tabs={tabs} hideSearchBar={isDifferentialView}> | ||
{children} | ||
</ProfilingAppPageTemplate> | ||
); | ||
} |
80 changes: 80 additions & 0 deletions
80
x-pack/plugins/profiling/public/views/functions/topn/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
import React from 'react'; | ||
import { AsyncComponent } from '../../../components/async_component'; | ||
import { useProfilingDependencies } from '../../../components/contexts/profiling_dependencies/use_profiling_dependencies'; | ||
import { TopNFunctionsTable } from '../../../components/topn_functions'; | ||
import { useProfilingParams } from '../../../hooks/use_profiling_params'; | ||
import { useProfilingRouter } from '../../../hooks/use_profiling_router'; | ||
import { useProfilingRoutePath } from '../../../hooks/use_profiling_route_path'; | ||
import { useTimeRange } from '../../../hooks/use_time_range'; | ||
import { useTimeRangeAsync } from '../../../hooks/use_time_range_async'; | ||
|
||
export function TopNFunctionsView() { | ||
const { | ||
path, | ||
query, | ||
query: { rangeFrom, rangeTo, kuery, sortDirection, sortField }, | ||
} = useProfilingParams('/functions/topn'); | ||
|
||
const timeRange = useTimeRange({ rangeFrom, rangeTo }); | ||
|
||
const { | ||
services: { fetchTopNFunctions }, | ||
} = useProfilingDependencies(); | ||
|
||
const state = useTimeRangeAsync( | ||
({ http }) => { | ||
return fetchTopNFunctions({ | ||
http, | ||
timeFrom: timeRange.inSeconds.start, | ||
timeTo: timeRange.inSeconds.end, | ||
startIndex: 0, | ||
endIndex: 100000, | ||
kuery, | ||
}); | ||
}, | ||
[timeRange.inSeconds.start, timeRange.inSeconds.end, kuery, fetchTopNFunctions] | ||
); | ||
|
||
const routePath = useProfilingRoutePath() as '/functions/topn'; | ||
|
||
const profilingRouter = useProfilingRouter(); | ||
|
||
return ( | ||
<> | ||
<EuiFlexGroup direction="column"> | ||
<EuiFlexItem> | ||
<EuiFlexGroup direction="row" gutterSize="s"> | ||
<EuiFlexItem> | ||
<AsyncComponent {...state} size="xl" alignTop> | ||
<TopNFunctionsTable | ||
topNFunctions={state.data} | ||
sortDirection={sortDirection} | ||
sortField={sortField} | ||
onSortChange={(nextSort) => { | ||
profilingRouter.push(routePath, { | ||
path, | ||
query: { | ||
...query, | ||
sortField: nextSort.sortField, | ||
sortDirection: nextSort.sortDirection, | ||
}, | ||
}); | ||
}} | ||
totalSeconds={timeRange.inSeconds.end - timeRange.inSeconds.start} | ||
isDifferentialView={false} | ||
/> | ||
</AsyncComponent> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</> | ||
); | ||
} |
188 changes: 0 additions & 188 deletions
188
x-pack/plugins/profiling/public/views/functions_view/index.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters