-
Notifications
You must be signed in to change notification settings - Fork 17
feat: serverless database view #2836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ca9986a
feat: serverless database view
astandrik 5947cad
fix: some review fixes
astandrik f0b8ec9
fix: review fixes
astandrik a336c9d
fix: code
astandrik 9c92d12
fix: better code
astandrik 65574d0
fix: better code
astandrik e78f7ec
fix: label
astandrik 610df88
fix: nanofix
astandrik cfb0d28
fix: better code
astandrik 044b80e
fix: code
astandrik d75bd92
fix: storage groups
astandrik bea42b4
fix: title
astandrik fc7df32
fix: refactoring
astandrik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| import {useMemo} from 'react'; | ||
|
||
|
|
||
| import {Flex} from '@gravity-ui/uikit'; | ||
| import {Link, useLocation} from 'react-router-dom'; | ||
|
|
||
|
|
@@ -11,7 +13,7 @@ import type { | |
| } from '../../../../../store/reducers/tenants/utils'; | ||
| import {cn} from '../../../../../utils/cn'; | ||
| import {SHOW_NETWORK_UTILIZATION} from '../../../../../utils/constants'; | ||
| import {useSetting, useTypedSelector} from '../../../../../utils/hooks'; | ||
| import {useSetting} from '../../../../../utils/hooks'; | ||
| import {calculateMetricAggregates} from '../../../../../utils/metrics'; | ||
| import { | ||
| formatCoresLegend, | ||
|
|
@@ -22,6 +24,8 @@ import {TenantTabsGroups, getTenantPath} from '../../../TenantPages'; | |
| import {TabCard} from '../TabCard/TabCard'; | ||
| import i18n from '../i18n'; | ||
|
|
||
| import {ServerlessPlaceholderTabs} from './ServerlessPlaceholderTabs'; | ||
|
|
||
| import './MetricsTabs.scss'; | ||
|
|
||
| const b = cn('tenant-metrics-tabs'); | ||
|
|
@@ -33,6 +37,8 @@ interface MetricsTabsProps { | |
| tabletStorageStats?: TenantStorageStats[]; | ||
| networkStats?: TenantMetricStats[]; | ||
| storageGroupsCount?: number; | ||
| isServerless?: boolean; | ||
| activeTab: TenantMetricsTab; | ||
| } | ||
|
|
||
| export function MetricsTabs({ | ||
|
|
@@ -42,9 +48,10 @@ export function MetricsTabs({ | |
| tabletStorageStats, | ||
| networkStats, | ||
| storageGroupsCount, | ||
| isServerless, | ||
| activeTab, | ||
| }: MetricsTabsProps) { | ||
| const location = useLocation(); | ||
| const {metricsTab} = useTypedSelector((state) => state.tenant); | ||
| const queryParams = parseQuery(location); | ||
|
|
||
| const tabLinks: Record<TenantMetricsTab, string> = { | ||
|
|
@@ -67,27 +74,37 @@ export function MetricsTabs({ | |
| }; | ||
|
|
||
| // Use only pools that directly indicate resources available to perform user queries | ||
| const cpuPools = (poolsCpuStats || []).filter( | ||
| (pool) => !(pool.name === 'Batch' || pool.name === 'IO'), | ||
| const cpuPools = useMemo( | ||
| () => | ||
| (poolsCpuStats || []).filter((pool) => !(pool.name === 'Batch' || pool.name === 'IO')), | ||
astandrik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| [poolsCpuStats], | ||
| ); | ||
astandrik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const cpuMetrics = calculateMetricAggregates(cpuPools); | ||
| const cpuMetrics = useMemo(() => calculateMetricAggregates(cpuPools), [cpuPools]); | ||
|
|
||
| // Calculate storage metrics using utility | ||
| const storageStats = tabletStorageStats || blobStorageStats || []; | ||
| const storageMetrics = calculateMetricAggregates(storageStats); | ||
| const storageStats = useMemo( | ||
| () => tabletStorageStats || blobStorageStats || [], | ||
| [tabletStorageStats, blobStorageStats], | ||
| ); | ||
| const storageMetrics = useMemo(() => calculateMetricAggregates(storageStats), [storageStats]); | ||
|
|
||
| // Calculate memory metrics using utility | ||
| const memoryMetrics = calculateMetricAggregates(memoryStats); | ||
| const memoryMetrics = useMemo(() => calculateMetricAggregates(memoryStats), [memoryStats]); | ||
|
|
||
| // Calculate network metrics using utility | ||
| const [showNetworkUtilization] = useSetting<boolean>(SHOW_NETWORK_UTILIZATION); | ||
| const networkMetrics = networkStats ? calculateMetricAggregates(networkStats) : null; | ||
| const networkMetrics = useMemo( | ||
| () => (networkStats ? calculateMetricAggregates(networkStats) : null), | ||
| [networkStats], | ||
| ); | ||
|
|
||
| const cardVariant = isServerless ? 'serverless' : 'default'; | ||
|
|
||
| return ( | ||
| <Flex className={b()} alignItems="center"> | ||
| <Flex className={b({serverless: Boolean(isServerless)})} alignItems="center"> | ||
| <div | ||
| className={b('link-container', { | ||
| active: metricsTab === TENANT_METRICS_TABS_IDS.cpu, | ||
| active: activeTab === TENANT_METRICS_TABS_IDS.cpu, | ||
| })} | ||
| > | ||
| <Link to={tabLinks.cpu} className={b('link')}> | ||
|
|
@@ -96,14 +113,16 @@ export function MetricsTabs({ | |
| value={cpuMetrics.totalUsed} | ||
| limit={cpuMetrics.totalLimit} | ||
| legendFormatter={formatCoresLegend} | ||
| active={metricsTab === TENANT_METRICS_TABS_IDS.cpu} | ||
| active={activeTab === TENANT_METRICS_TABS_IDS.cpu} | ||
| helpText={i18n('context_cpu-description')} | ||
| variant={cardVariant} | ||
| subtitle={isServerless ? i18n('context_serverless-autoscaled') : undefined} | ||
| /> | ||
| </Link> | ||
| </div> | ||
| <div | ||
| className={b('link-container', { | ||
| active: metricsTab === TENANT_METRICS_TABS_IDS.storage, | ||
| active: activeTab === TENANT_METRICS_TABS_IDS.storage, | ||
| })} | ||
| > | ||
| <Link to={tabLinks.storage} className={b('link')}> | ||
|
|
@@ -116,44 +135,62 @@ export function MetricsTabs({ | |
| value={storageMetrics.totalUsed} | ||
| limit={storageMetrics.totalLimit} | ||
| legendFormatter={formatStorageLegend} | ||
| active={metricsTab === TENANT_METRICS_TABS_IDS.storage} | ||
| active={activeTab === TENANT_METRICS_TABS_IDS.storage} | ||
| helpText={i18n('context_storage-description')} | ||
| variant={cardVariant} | ||
| subtitle={ | ||
| isServerless && storageMetrics.totalLimit | ||
| ? i18n('context_serverless-storage-subtitle', { | ||
| groups: String(storageGroupsCount ?? 0), | ||
| legend: formatStorageLegend({ | ||
| value: storageMetrics.totalUsed, | ||
| capacity: storageMetrics.totalLimit, | ||
| }), | ||
| }) | ||
| : undefined | ||
| } | ||
| /> | ||
| </Link> | ||
| </div> | ||
| <div | ||
| className={b('link-container', { | ||
| active: metricsTab === TENANT_METRICS_TABS_IDS.memory, | ||
| })} | ||
| > | ||
| <Link to={tabLinks.memory} className={b('link')}> | ||
| <TabCard | ||
| text={i18n('context_memory-used')} | ||
| value={memoryMetrics.totalUsed} | ||
| limit={memoryMetrics.totalLimit} | ||
| legendFormatter={formatStorageLegend} | ||
| active={metricsTab === TENANT_METRICS_TABS_IDS.memory} | ||
| helpText={i18n('context_memory-description')} | ||
| /> | ||
| </Link> | ||
| </div> | ||
| {showNetworkUtilization && networkStats && networkMetrics && ( | ||
| <div | ||
| className={b('link-container', { | ||
| active: metricsTab === TENANT_METRICS_TABS_IDS.network, | ||
| })} | ||
| > | ||
| <Link to={tabLinks.network} className={b('link')}> | ||
| <TabCard | ||
| text={i18n('context_network-usage')} | ||
| value={networkMetrics.totalUsed} | ||
| limit={networkMetrics.totalLimit} | ||
| legendFormatter={formatSpeedLegend} | ||
| active={metricsTab === TENANT_METRICS_TABS_IDS.network} | ||
| helpText={i18n('context_network-description')} | ||
| /> | ||
| </Link> | ||
| </div> | ||
| {isServerless ? ( | ||
| <ServerlessPlaceholderTabs /> | ||
| ) : ( | ||
| <> | ||
| <div | ||
| className={b('link-container', { | ||
| active: activeTab === TENANT_METRICS_TABS_IDS.memory, | ||
| })} | ||
| > | ||
| <Link to={tabLinks.memory} className={b('link')}> | ||
| <TabCard | ||
| text={i18n('context_memory-used')} | ||
| value={memoryMetrics.totalUsed} | ||
| limit={memoryMetrics.totalLimit} | ||
| legendFormatter={formatStorageLegend} | ||
| active={activeTab === TENANT_METRICS_TABS_IDS.memory} | ||
| helpText={i18n('context_memory-description')} | ||
| /> | ||
| </Link> | ||
| </div> | ||
| {showNetworkUtilization && networkStats && networkMetrics && ( | ||
| <div | ||
| className={b('link-container', { | ||
| active: activeTab === TENANT_METRICS_TABS_IDS.network, | ||
| })} | ||
| > | ||
| <Link to={tabLinks.network} className={b('link')}> | ||
| <TabCard | ||
| text={i18n('context_network-usage')} | ||
| value={networkMetrics.totalUsed} | ||
| limit={networkMetrics.totalLimit} | ||
| legendFormatter={formatSpeedLegend} | ||
| active={activeTab === TENANT_METRICS_TABS_IDS.network} | ||
| helpText={i18n('context_network-description')} | ||
| /> | ||
| </Link> | ||
| </div> | ||
| )} | ||
| </> | ||
| )} | ||
| </Flex> | ||
| ); | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.