Skip to content

Commit 1822f35

Browse files
committed
fix: write network info for tenant same as for cluster
1 parent 7eb1f2f commit 1822f35

File tree

15 files changed

+459
-367
lines changed

15 files changed

+459
-367
lines changed

src/containers/Tenant/Diagnostics/TenantOverview/MetricsTabs/CommonMetricsTabs.tsx

Lines changed: 0 additions & 89 deletions
This file was deleted.

src/containers/Tenant/Diagnostics/TenantOverview/MetricsTabs/DedicatedMetricsTabs.tsx

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/containers/Tenant/Diagnostics/TenantOverview/MetricsTabs/MetricsTabs.tsx

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ import {calculateMetricAggregates} from '../../../../../utils/metrics';
1919
// no direct legend formatters needed here – handled in subcomponents
2020
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
2121

22-
import {CommonMetricsTabs} from './CommonMetricsTabs';
23-
import {DedicatedMetricsTabs} from './DedicatedMetricsTabs';
24-
import {ServerlessPlaceholderTabs} from './ServerlessPlaceholderTabs';
22+
import {CpuTab} from './components/CpuTab';
23+
import {MemoryTab} from './components/MemoryTab';
24+
import {NetworkTab} from './components/NetworkTab';
25+
import {PlaceholderTab} from './components/PlaceholderTab';
26+
import {StorageTab} from './components/StorageTab';
2527

2628
import './MetricsTabs.scss';
2729

@@ -32,7 +34,8 @@ interface MetricsTabsProps {
3234
memoryStats?: TenantMetricStats[];
3335
blobStorageStats?: TenantStorageStats[];
3436
tabletStorageStats?: TenantStorageStats[];
35-
networkStats?: TenantMetricStats[];
37+
networkUtilization?: number;
38+
networkThroughput?: number;
3639
storageGroupsCount?: number;
3740
databaseType?: ETenantType;
3841
activeTab: TenantMetricsTab;
@@ -43,7 +46,8 @@ export function MetricsTabs({
4346
memoryStats,
4447
blobStorageStats,
4548
tabletStorageStats,
46-
networkStats,
49+
networkUtilization,
50+
networkThroughput,
4751
storageGroupsCount,
4852
databaseType,
4953
activeTab,
@@ -88,42 +92,51 @@ export function MetricsTabs({
8892
// Calculate memory metrics using utility
8993
const memoryMetrics = useMemo(() => calculateMetricAggregates(memoryStats), [memoryStats]);
9094

91-
// Calculate network metrics using utility
95+
// Pass raw network values; DedicatedMetricsTabs computes percent and legend
9296
const [showNetworkUtilization] = useSetting<boolean>(SHOW_NETWORK_UTILIZATION);
93-
const networkMetrics = useMemo(
94-
() => (networkStats ? calculateMetricAggregates(networkStats) : null),
95-
[networkStats],
96-
);
9797

9898
// card variant is handled within subcomponents
9999

100100
const isServerless = databaseType === 'Serverless';
101101

102102
return (
103103
<Flex className={b({serverless: Boolean(isServerless)})} alignItems="center">
104-
<CommonMetricsTabs
105-
activeTab={activeTab}
106-
tabLinks={tabLinks}
104+
<CpuTab
105+
to={tabLinks[TENANT_METRICS_TABS_IDS.cpu]}
106+
active={activeTab === TENANT_METRICS_TABS_IDS.cpu}
107+
isServerless={Boolean(isServerless)}
107108
cpu={{totalUsed: cpuMetrics.totalUsed, totalLimit: cpuMetrics.totalLimit}}
109+
/>
110+
<StorageTab
111+
to={tabLinks[TENANT_METRICS_TABS_IDS.storage]}
112+
active={activeTab === TENANT_METRICS_TABS_IDS.storage}
113+
isServerless={Boolean(isServerless)}
108114
storage={{
109115
totalUsed: storageMetrics.totalUsed,
110116
totalLimit: storageMetrics.totalLimit,
111117
}}
112118
storageGroupsCount={storageGroupsCount}
113-
databaseType={databaseType}
114119
/>
115120
{isServerless ? (
116-
<ServerlessPlaceholderTabs />
121+
<PlaceholderTab />
117122
) : (
118-
<DedicatedMetricsTabs
119-
activeTab={activeTab}
120-
tabLinks={tabLinks}
123+
<MemoryTab
124+
to={tabLinks[TENANT_METRICS_TABS_IDS.memory]}
125+
active={activeTab === TENANT_METRICS_TABS_IDS.memory}
121126
memory={{
122127
totalUsed: memoryMetrics.totalUsed,
123128
totalLimit: memoryMetrics.totalLimit,
124129
}}
125-
network={networkMetrics}
126-
showNetwork={Boolean(showNetworkUtilization && networkStats && networkMetrics)}
130+
/>
131+
)}
132+
{isServerless || !showNetworkUtilization ? (
133+
<PlaceholderTab />
134+
) : (
135+
<NetworkTab
136+
to={tabLinks[TENANT_METRICS_TABS_IDS.network]}
137+
active={activeTab === TENANT_METRICS_TABS_IDS.network}
138+
networkUtilization={networkUtilization}
139+
networkThroughput={networkThroughput}
127140
/>
128141
)}
129142
</Flex>

src/containers/Tenant/Diagnostics/TenantOverview/MetricsTabs/ServerlessPlaceholderTabs.tsx

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import {Link} from 'react-router-dom';
2+
3+
import {cn} from '../../../../../../utils/cn';
4+
import {formatCoresLegend} from '../../../../../../utils/metrics/formatMetricLegend';
5+
import {ServerlessTabCard} from '../../TabCard/ServerlessTabCard';
6+
import {UsageTabCard} from '../../TabCard/UsageTabCard';
7+
import i18n from '../../i18n';
8+
9+
import '../MetricsTabs.scss';
10+
11+
const b = cn('tenant-metrics-tabs');
12+
13+
interface CpuTabProps {
14+
to: string;
15+
active: boolean;
16+
isServerless: boolean;
17+
cpu: {totalUsed: number; totalLimit: number};
18+
}
19+
20+
export function CpuTab({to, active, isServerless, cpu}: CpuTabProps) {
21+
return (
22+
<div className={b('link-container', {active})}>
23+
<Link to={to} className={b('link')}>
24+
{isServerless ? (
25+
<ServerlessTabCard
26+
text={i18n('context_cpu-load')}
27+
active={active}
28+
helpText={i18n('context_cpu-description')}
29+
subtitle={i18n('context_serverless-autoscaled')}
30+
/>
31+
) : (
32+
<UsageTabCard
33+
text={i18n('context_cpu-load')}
34+
value={cpu.totalUsed}
35+
limit={cpu.totalLimit}
36+
legendFormatter={formatCoresLegend}
37+
active={active}
38+
helpText={i18n('context_cpu-description')}
39+
/>
40+
)}
41+
</Link>
42+
</div>
43+
);
44+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {Link} from 'react-router-dom';
2+
3+
import {cn} from '../../../../../../utils/cn';
4+
import {formatStorageLegend} from '../../../../../../utils/metrics/formatMetricLegend';
5+
import {UsageTabCard} from '../../TabCard/UsageTabCard';
6+
import i18n from '../../i18n';
7+
8+
import '../MetricsTabs.scss';
9+
10+
const b = cn('tenant-metrics-tabs');
11+
12+
interface MemoryTabProps {
13+
to: string;
14+
active: boolean;
15+
memory: {totalUsed: number; totalLimit: number};
16+
}
17+
18+
export function MemoryTab({to, active, memory}: MemoryTabProps) {
19+
return (
20+
<div className={b('link-container', {active})}>
21+
<Link to={to} className={b('link')}>
22+
<UsageTabCard
23+
text={i18n('context_memory-used')}
24+
value={memory.totalUsed}
25+
limit={memory.totalLimit}
26+
legendFormatter={formatStorageLegend}
27+
active={active}
28+
helpText={i18n('context_memory-description')}
29+
/>
30+
</Link>
31+
</div>
32+
);
33+
}

0 commit comments

Comments
 (0)