feat(platform): expose active connection capacity

This commit is contained in:
lingniu
2026-07-04 08:52:57 +08:00
parent b26a37f6f7
commit e29f8768ca
6 changed files with 49 additions and 17 deletions

View File

@@ -274,6 +274,7 @@ export interface QualityBucketStat {
export interface OpsHealth {
linkHealth: LinkHealth[];
kafkaLag: number | null;
activeConnections: number | null;
redisOnlineKeys: number | null;
tdengineWritable: boolean;
mysqlWritable: boolean;

View File

@@ -188,8 +188,8 @@ export function Quality({
</div>
<Row gutter={16}>
<Col span={6}><Card bordered title="Kafka Lag">{formatLag(health?.kafkaLag)}</Card></Col>
<Col span={6}><Card bordered title="活跃连接">{formatLag(health?.activeConnections)}</Card></Col>
<Col span={6}><Card bordered title="Redis 在线 Key">{formatLag(health?.redisOnlineKeys)}</Card></Col>
<Col span={6}><Card bordered title="BFF 请求超时">{formatRequestTimeout(health)}</Card></Col>
<Col span={6}>
<Card bordered title="存储读取">
<Tag color={statusColor[storageReadStatus(health)] ?? 'grey'}>

View File

@@ -4128,6 +4128,31 @@ test('quality health storage card stays pending before ops health loads', async
expect(screen.queryByText('异常')).not.toBeInTheDocument();
});
test('quality health shows active connection capacity metric', async () => {
window.history.replaceState(null, '', '/#/quality');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
return {
ok: true,
json: async () => ({
data: path.includes('/api/ops/health')
? { linkHealth: [], kafkaLag: 0, activeConnections: 120000, redisOnlineKeys: 368, tdengineWritable: true, mysqlWritable: true, runtime: { requestTimeoutMs: 5000 } }
: path.includes('/api/quality/summary')
? { issueVehicleCount: 0, issueRecordCount: 0, errorCount: 0, warningCount: 0, protocols: [], issueTypes: [] }
: { items: [], total: 0, limit: 20, offset: 0 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
});
render(<App />);
expect(await screen.findByRole('heading', { name: '质量治理' })).toBeInTheDocument();
expect(await screen.findByText('活跃连接')).toBeInTheDocument();
expect(screen.getByText('120,000')).toBeInTheDocument();
});
test('shows vehicle service evidence chain before source details', async () => {
window.history.replaceState(null, '', '/#/detail?keyword=VIN001');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {