feat(platform): expose structured capacity metrics

This commit is contained in:
lingniu
2026-07-04 19:10:04 +08:00
parent 68b260c704
commit cbe7882d51
10 changed files with 297 additions and 42 deletions

View File

@@ -3374,6 +3374,18 @@ test('renders ops quality as a standalone runtime health page', async () => {
],
kafkaLag: 42,
activeConnections: 1234,
capacityMetrics: {
activeConnections: 1234,
kafkaLag: 42,
bridgeConsumerPending: 1482047,
bridgeAckPending: 4000,
bridgeBatchPendingMessages: 12,
fastWriterConsumerPending: 8,
fastWriterAckPending: 0,
fastWriterBatchPending: 0,
historyBatchPending: 2,
historyRowsPending: 320
},
capacityFindings: [
'Kafka lag 42',
'bridge ack pending 4000 exceeds 100',
@@ -3413,7 +3425,7 @@ test('renders ops quality as a standalone runtime health page', async () => {
expect(await screen.findByRole('heading', { name: '运维质量' })).toBeInTheDocument();
expect(screen.getByText('platform-ops-test')).toBeInTheDocument();
expect(screen.getAllByText('42').length).toBeGreaterThanOrEqual(1);
expect(screen.getByText('1,234')).toBeInTheDocument();
expect(screen.getAllByText('1,234').length).toBeGreaterThanOrEqual(1);
expect(screen.getByText('368')).toBeInTheDocument();
expect(screen.getByText('TDengine 写入')).toBeInTheDocument();
expect(screen.getByText('MySQL 写入')).toBeInTheDocument();
@@ -3421,9 +3433,14 @@ test('renders ops quality as a standalone runtime health page', async () => {
expect(screen.getByText('/_AMapService')).toBeInTheDocument();
expect(screen.getByText('安全码未暴露')).toBeInTheDocument();
expect(screen.getByText('gb32960-gateway')).toBeInTheDocument();
expect(screen.getByText('消息链路积压')).toBeInTheDocument();
expect(screen.getByText('快速写入待消费')).toBeInTheDocument();
expect(screen.getByText('历史行待写')).toBeInTheDocument();
expect(screen.getByText('1,482,047')).toBeInTheDocument();
expect(screen.getByText('4,000')).toBeInTheDocument();
expect(screen.getByText('Kafka lag 42')).toBeInTheDocument();
expect(screen.getByText('NATS 桥接 ACK 未确认')).toBeInTheDocument();
expect(screen.getByText('NATS 桥接待消费')).toBeInTheDocument();
expect(screen.getAllByText('NATS 桥接待消费').length).toBeGreaterThanOrEqual(1);
expect(screen.getByText('桥接处置顺序')).toBeInTheDocument();
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/ops/health'), undefined);
});