feat: localize performance monitoring
This commit is contained in:
1 parent
a069bb1bf1
commit
76c21b39b1
3 files changed
+45
-43
No files matched your search
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { Connection, RefreshRight, TopRight } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import * as echarts from 'echarts/core'
|
||||
@@ -60,12 +61,8 @@ interface PerformanceReport {
|
||||
databaseQueries: RankingItem[]
|
||||
}
|
||||
|
||||
const rangeOptions: { value: ReportRange; label: string }[] = [
|
||||
{ value: '15m', label: '15 分钟' },
|
||||
{ value: '1h', label: '1 小时' },
|
||||
{ value: '24h', label: '24 小时' },
|
||||
{ value: '7d', label: '7 天' },
|
||||
]
|
||||
const { locale, t } = useI18n()
|
||||
const rangeOptions = computed(() => (['15m', '1h', '24h', '7d'] as ReportRange[]).map(value => ({ value, label: t(`performance.ranges.${value}`) })))
|
||||
|
||||
const range = ref<ReportRange>('1h')
|
||||
const loading = ref(true)
|
||||
@@ -81,19 +78,19 @@ const hasSamples = computed(() =>
|
||||
|
||||
const operatingNote = computed(() => {
|
||||
const headline = report.value?.headline
|
||||
if (!headline) return '等待指标样本'
|
||||
if (!headline) return t('performance.notes.waiting')
|
||||
if ((headline.failedDatabaseCommandCount ?? 0) > 0)
|
||||
return '存在失败的数据库命令'
|
||||
return t('performance.notes.failedDatabase')
|
||||
if ((headline.serverErrorRatePercent ?? 0) >= 1)
|
||||
return '服务端错误率需要关注'
|
||||
return t('performance.notes.serverErrors')
|
||||
if ((headline.slowDatabaseCommandCount ?? 0) > 0)
|
||||
return '存在超过阈值的慢查询'
|
||||
return '当前采样窗口内未见明显异常'
|
||||
return t('performance.notes.slowQueries')
|
||||
return t('performance.notes.healthy')
|
||||
})
|
||||
|
||||
function formatNumber(value?: number, digits = 0) {
|
||||
if (value == null || !Number.isFinite(value)) return '—'
|
||||
return value.toLocaleString('zh-CN', {
|
||||
return value.toLocaleString(locale.value, {
|
||||
maximumFractionDigits: digits,
|
||||
minimumFractionDigits: digits,
|
||||
})
|
||||
@@ -101,7 +98,7 @@ function formatNumber(value?: number, digits = 0) {
|
||||
|
||||
function formatTime(value?: string) {
|
||||
if (!value) return '—'
|
||||
return new Date(value).toLocaleString('zh-CN', {
|
||||
return new Date(value).toLocaleString(locale.value, {
|
||||
hour12: false,
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
@@ -111,7 +108,7 @@ function formatTime(value?: string) {
|
||||
}
|
||||
|
||||
function formatAxisTime(value: string) {
|
||||
return new Date(value).toLocaleString('zh-CN', {
|
||||
return new Date(value).toLocaleString(locale.value, {
|
||||
hour12: false,
|
||||
month: range.value === '7d' ? '2-digit' : undefined,
|
||||
day: range.value === '7d' ? '2-digit' : undefined,
|
||||
@@ -198,7 +195,7 @@ function renderChart() {
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value',
|
||||
name: '请求 / 秒',
|
||||
name: t('performance.requestsPerSecond'),
|
||||
nameTextStyle: { color: '#63727b', fontSize: 10 },
|
||||
splitLine: { lineStyle: { color: '#e8edef', type: 'dashed' } },
|
||||
axisLabel: { color: '#79878f', fontSize: 10 },
|
||||
@@ -213,7 +210,7 @@ function renderChart() {
|
||||
],
|
||||
series: [
|
||||
{
|
||||
name: '请求速率',
|
||||
name: t('performance.requestRate'),
|
||||
type: 'line',
|
||||
smooth: 0.22,
|
||||
symbol: 'none',
|
||||
@@ -224,7 +221,7 @@ function renderChart() {
|
||||
),
|
||||
},
|
||||
{
|
||||
name: '接口 P95',
|
||||
name: t('performance.endpointP95'),
|
||||
type: 'line',
|
||||
yAxisIndex: 1,
|
||||
smooth: 0.22,
|
||||
@@ -257,11 +254,10 @@ onUnmounted(disposeChart)
|
||||
<header class="performance-heading">
|
||||
<div>
|
||||
<span>PERFORMANCE RAIL / {{ report?.dataSource?.toUpperCase() || 'PROMETHEUS' }}</span>
|
||||
<h3 id="performance-title">系统性能</h3>
|
||||
<p>从接口进入数据库,定位响应时间消耗在哪里。</p>
|
||||
<h3 id="performance-title">{{ t('performance.title') }}</h3><p>{{ t('performance.description') }}</p>
|
||||
</div>
|
||||
<div class="performance-actions">
|
||||
<div class="range-switch" aria-label="性能报表时间范围">
|
||||
<div class="range-switch" :aria-label="t('performance.rangeAria')">
|
||||
<button
|
||||
v-for="item in rangeOptions"
|
||||
:key="item.value"
|
||||
@@ -277,7 +273,7 @@ onUnmounted(disposeChart)
|
||||
circle
|
||||
:icon="RefreshRight"
|
||||
:loading="loading"
|
||||
aria-label="刷新性能报表"
|
||||
:aria-label="t('performance.refreshAria')"
|
||||
@click="loadReport"
|
||||
/>
|
||||
</div>
|
||||
@@ -295,11 +291,11 @@ onUnmounted(disposeChart)
|
||||
<el-icon><Connection /></el-icon>
|
||||
<div>
|
||||
<strong>
|
||||
{{ report?.status === 'not_configured' ? '等待连接性能数据源' : '性能数据暂不可用' }}
|
||||
{{ t(report?.status === 'not_configured' ? 'performance.notConfigured' : 'performance.unavailable') }}
|
||||
</strong>
|
||||
<p>{{ report?.detail }}</p>
|
||||
<small>
|
||||
业务接口继续正常运行;报表不会回退读取教务业务数据库。
|
||||
{{ t('performance.fallbackNote') }}
|
||||
</small>
|
||||
</div>
|
||||
<a
|
||||
@@ -308,7 +304,7 @@ onUnmounted(disposeChart)
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
打开监控平台
|
||||
{{ t('performance.openDashboard') }}
|
||||
<el-icon><TopRight /></el-icon>
|
||||
</a>
|
||||
</div>
|
||||
@@ -316,7 +312,7 @@ onUnmounted(disposeChart)
|
||||
<template v-else>
|
||||
<div class="performance-strip">
|
||||
<div class="strip-lead">
|
||||
<span>采样结论</span>
|
||||
<span>{{ t('performance.sampleConclusion') }}</span>
|
||||
<strong>{{ operatingNote }}</strong>
|
||||
<small>
|
||||
{{ formatTime(report.from) }} — {{ formatTime(report.to) }}
|
||||
@@ -324,37 +320,37 @@ onUnmounted(disposeChart)
|
||||
</div>
|
||||
<dl>
|
||||
<div>
|
||||
<dt>请求总量</dt>
|
||||
<dt>{{ t('performance.requestCount') }}</dt>
|
||||
<dd>{{ formatNumber(report.headline?.requestCount) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>接口 P95</dt>
|
||||
<dt>{{ t('performance.endpointP95') }}</dt>
|
||||
<dd>{{ formatNumber(report.headline?.requestP95Milliseconds, 1) }}<small>ms</small></dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>5xx 比例</dt>
|
||||
<dt>{{ t('performance.errorRate') }}</dt>
|
||||
<dd>{{ formatNumber(report.headline?.serverErrorRatePercent, 2) }}<small>%</small></dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>数据库 P95</dt>
|
||||
<dt>{{ t('performance.databaseP95') }}</dt>
|
||||
<dd>{{ formatNumber(report.headline?.databaseP95Milliseconds, 1) }}<small>ms</small></dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>慢查询</dt>
|
||||
<dt>{{ t('performance.slowQueries') }}</dt>
|
||||
<dd>{{ formatNumber(report.headline?.slowDatabaseCommandCount) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>查询失败</dt>
|
||||
<dt>{{ t('performance.queryFailures') }}</dt>
|
||||
<dd>{{ formatNumber(report.headline?.failedDatabaseCommandCount) }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div v-if="hasSamples" class="performance-rail">
|
||||
<div ref="chartElement" class="rail-chart" aria-label="请求速率与接口 P95 趋势图" />
|
||||
<div ref="chartElement" class="rail-chart" :aria-label="t('performance.chartAria')" />
|
||||
</div>
|
||||
<div v-else class="samples-empty">
|
||||
数据源已连接,但该时间范围内尚未收到请求指标。
|
||||
{{ t('performance.noSamples') }}
|
||||
</div>
|
||||
|
||||
<div class="rankings">
|
||||
@@ -362,9 +358,9 @@ onUnmounted(disposeChart)
|
||||
<div class="ranking-heading">
|
||||
<div>
|
||||
<span>HTTP ROUTES</span>
|
||||
<h4>接口耗时排行</h4>
|
||||
<h4>{{ t('performance.endpointRanking') }}</h4>
|
||||
</div>
|
||||
<small>P95 / 请求量 / 5xx</small>
|
||||
<small>{{ t('performance.endpointMetrics') }}</small>
|
||||
</div>
|
||||
<div v-if="report.endpoints.length" class="ranking-list">
|
||||
<div
|
||||
@@ -383,20 +379,20 @@ onUnmounted(disposeChart)
|
||||
</div>
|
||||
<dl>
|
||||
<dd>{{ formatNumber(item.p95Milliseconds, 1) }} ms</dd>
|
||||
<dt>{{ formatNumber(item.requestCount) }} 次 · {{ formatNumber(item.exceptionalCount) }} 错误</dt>
|
||||
<dt>{{ t('performance.endpointCounts', { count: formatNumber(item.requestCount), errors: formatNumber(item.exceptionalCount) }) }}</dt>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="ranking-empty">该范围内没有接口指标。</p>
|
||||
<p v-else class="ranking-empty">{{ t('performance.noEndpoints') }}</p>
|
||||
</article>
|
||||
|
||||
<article class="ranking-board database-board">
|
||||
<div class="ranking-heading">
|
||||
<div>
|
||||
<span>DATABASE QUERIES</span>
|
||||
<h4>数据库查询排行</h4>
|
||||
<h4>{{ t('performance.databaseRanking') }}</h4>
|
||||
</div>
|
||||
<small>P95 / 调用量 / 慢查询</small>
|
||||
<small>{{ t('performance.databaseMetrics') }}</small>
|
||||
</div>
|
||||
<div v-if="report.databaseQueries.length" class="ranking-list">
|
||||
<div
|
||||
@@ -415,23 +411,23 @@ onUnmounted(disposeChart)
|
||||
</div>
|
||||
<dl>
|
||||
<dd>{{ formatNumber(item.p95Milliseconds, 1) }} ms</dd>
|
||||
<dt>{{ formatNumber(item.requestCount) }} 次 · {{ formatNumber(item.exceptionalCount) }} 慢</dt>
|
||||
<dt>{{ t('performance.databaseCounts', { count: formatNumber(item.requestCount), slow: formatNumber(item.exceptionalCount) }) }}</dt>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="ranking-empty">该范围内没有数据库指标。</p>
|
||||
<p v-else class="ranking-empty">{{ t('performance.noDatabase') }}</p>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<footer class="performance-foot">
|
||||
<span>生成于 {{ formatTime(report.generatedAt) }} · 页面数据采用短时缓存</span>
|
||||
<span>{{ t('performance.generatedAt', { date: formatTime(report.generatedAt) }) }}</span>
|
||||
<a
|
||||
v-if="report.dashboardUrl"
|
||||
:href="report.dashboardUrl"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
查看原始调用链
|
||||
{{ t('performance.viewTraces') }}
|
||||
<el-icon><TopRight /></el-icon>
|
||||
</a>
|
||||
</footer>
|
||||
|
||||
@@ -181,6 +181,9 @@ export default {
|
||||
teachingPreferences: {
|
||||
teacherTitle: 'Teaching course applications', reviewerTitle: 'Teaching eligibility review', teacherDescription: 'Apply for courses you are willing to teach before scheduling. College approval is required before public-course teaching tasks can be assigned.', reviewerDescription: 'Review teacher applications or assign teachers directly. Approved teachers enter the eligible pool for the selected term and course.', apply: 'Apply for course', assign: 'Assign teacher directly', teacher: 'Teacher', selectTermSubject: 'Select term and course', college: 'College', reviewAssign: 'Review or assign directly', academicOffice: 'Academic affairs', mergeAssign: 'Merge classes and assign teacher', scheduling: 'Scheduling', generateTimetable: 'Generate timetable', allTerms: 'All terms', allStatuses: 'All statuses', refresh: 'Refresh', total: '{count} records', applicant: 'Applicant', course: 'Applied course', term: 'Term', statement: 'Application statement', status: 'Status', reviewComment: 'Review comment', actions: 'Actions', withdraw: 'Withdraw', review: 'Review', processed: 'Processed', emptyTeacher: 'No teaching course applications', emptyReviewer: 'No applications awaiting review', submitTitle: 'Apply for a teaching course', proposedCourse: 'Proposed course', statementPlaceholder: 'Describe relevant teaching experience, research interests, or other context', cancel: 'Cancel', submitReview: 'Submit for college review', reviewTitle: 'Review teaching eligibility', teacherStatement: 'Teacher statement', notProvided: 'Not provided', conclusion: 'Decision', approve: 'Approve', reject: 'Reject', confirmReview: 'Confirm review', assignmentTitle: 'Assign teaching eligibility directly', assignmentHint: 'No teacher application is required. Saving immediately grants eligibility for the selected term and course.', teacherPlaceholder: 'Select by employee number or name', courseLabel: 'Course', coursePlaceholder: 'Select by code or name', credits: '{count} credits', assignmentComment: 'Assignment note', assignmentPlaceholder: 'Enter department arrangements, specialization, or other basis', confirmAssign: 'Confirm assignment', statuses: { Pending: 'Pending review', Approved: 'Approved', Rejected: 'Rejected', Withdrawn: 'Withdrawn' }, messages: { selectTermCourse: 'Select a term and course.', submitted: 'Course application submitted for college review.', withdrawConfirm: 'Withdraw the teaching application for “{course}”?', withdrawTitle: 'Withdraw application', approved: 'Application approved.', rejected: 'Application rejected.', selectAll: 'Select a term, teacher, and course.', assigned: 'Teaching eligibility assigned directly.' },
|
||||
},
|
||||
performance: {
|
||||
title: 'System performance', description: 'Trace response-time costs from API endpoints into the database.', rangeAria: 'Performance report time range', refreshAria: 'Refresh performance report', notConfigured: 'Waiting for a performance data source', unavailable: 'Performance data is unavailable', fallbackNote: 'Business APIs continue operating normally. The report will not fall back to reading the academic business database.', openDashboard: 'Open monitoring platform', sampleConclusion: 'Sample conclusion', requestCount: 'Total requests', endpointP95: 'Endpoint P95', errorRate: '5xx rate', databaseP95: 'Database P95', slowQueries: 'Slow queries', queryFailures: 'Query failures', chartAria: 'Request rate and endpoint P95 trend', noSamples: 'The data source is connected, but no request metrics were received in this time range.', endpointRanking: 'Endpoint latency ranking', endpointMetrics: 'P95 / requests / 5xx', endpointCounts: '{count} requests · {errors} errors', noEndpoints: 'No endpoint metrics in this range.', databaseRanking: 'Database query ranking', databaseMetrics: 'P95 / calls / slow queries', databaseCounts: '{count} calls · {slow} slow', noDatabase: 'No database metrics in this range.', generatedAt: 'Generated {date} · Page data uses a short cache', viewTraces: 'View raw traces', requestsPerSecond: 'Requests / second', requestRate: 'Request rate', ranges: { '15m': '15 minutes', '1h': '1 hour', '24h': '24 hours', '7d': '7 days' }, notes: { waiting: 'Waiting for metric samples', failedDatabase: 'Database command failures detected', serverErrors: 'Server error rate needs attention', slowQueries: 'Queries exceeded the slow-query threshold', healthy: 'No significant anomalies in the current sample window' },
|
||||
},
|
||||
api: {
|
||||
'data.constraint_conflict': 'A data constraint conflict occurred.',
|
||||
'server.unhandled_error': 'The server encountered an error while processing the request.',
|
||||
|
||||
@@ -181,6 +181,9 @@ export default {
|
||||
teachingPreferences: {
|
||||
teacherTitle: '授课科目申报', reviewerTitle: '授课资格审核', teacherDescription: '在排课前申报本学期愿意承担的课程,学院审核通过后才能分配公共课教学任务。', reviewerDescription: '审核教师申报,或由学院直接指定教师;通过后进入相应学期和课程的可分配教师池。', apply: '申报课程', assign: '直接分配教师', teacher: '教师', selectTermSubject: '选择学期与科目', college: '学院', reviewAssign: '审核或直接分配', academicOffice: '教务', mergeAssign: '合班并分配教师', scheduling: '排课', generateTimetable: '生成课表', allTerms: '全部学期', allStatuses: '全部状态', refresh: '刷新', total: '共 {count} 条', applicant: '申报教师', course: '申报课程', term: '学期', statement: '申报说明', status: '状态', reviewComment: '审核意见', actions: '操作', withdraw: '撤回', review: '审核', processed: '已处理', emptyTeacher: '尚未申报授课科目', emptyReviewer: '没有待处理的授课申报', submitTitle: '申报授课科目', proposedCourse: '拟授课程', statementPlaceholder: '可填写相关教学经历、研究方向或其他说明', cancel: '取消', submitReview: '提交学院审核', reviewTitle: '审核授课资格', teacherStatement: '教师说明', notProvided: '未填写', conclusion: '审核结论', approve: '通过', reject: '驳回', confirmReview: '确认审核', assignmentTitle: '直接分配授课教师', assignmentHint: '无需教师先申报,保存后立即取得所选学期与课程的授课资格。', teacherPlaceholder: '按工号或姓名选择', courseLabel: '课程', coursePlaceholder: '按编码或名称选择', credits: '{count} 学分', assignmentComment: '分配说明', assignmentPlaceholder: '可填写教研室安排、专业方向等依据', confirmAssign: '确认分配', statuses: { Pending: '待审核', Approved: '已通过', Rejected: '已驳回', Withdrawn: '已撤回' }, messages: { selectTermCourse: '请选择学期和课程。', submitted: '课程申报已提交,等待学院审核。', withdrawConfirm: '撤回“{course}”的授课申报?', withdrawTitle: '撤回申报', approved: '已审核通过。', rejected: '已驳回申报。', selectAll: '请选择学期、教师和课程。', assigned: '授课资格已直接分配。' },
|
||||
},
|
||||
performance: {
|
||||
title: '系统性能', description: '从接口进入数据库,定位响应时间消耗在哪里。', rangeAria: '性能报表时间范围', refreshAria: '刷新性能报表', notConfigured: '等待连接性能数据源', unavailable: '性能数据暂不可用', fallbackNote: '业务接口继续正常运行;报表不会回退读取教务业务数据库。', openDashboard: '打开监控平台', sampleConclusion: '采样结论', requestCount: '请求总量', endpointP95: '接口 P95', errorRate: '5xx 比例', databaseP95: '数据库 P95', slowQueries: '慢查询', queryFailures: '查询失败', chartAria: '请求速率与接口 P95 趋势图', noSamples: '数据源已连接,但该时间范围内尚未收到请求指标。', endpointRanking: '接口耗时排行', endpointMetrics: 'P95 / 请求量 / 5xx', endpointCounts: '{count} 次 · {errors} 错误', noEndpoints: '该范围内没有接口指标。', databaseRanking: '数据库查询排行', databaseMetrics: 'P95 / 调用量 / 慢查询', databaseCounts: '{count} 次 · {slow} 慢', noDatabase: '该范围内没有数据库指标。', generatedAt: '生成于 {date} · 页面数据采用短时缓存', viewTraces: '查看原始调用链', requestsPerSecond: '请求 / 秒', requestRate: '请求速率', ranges: { '15m': '15 分钟', '1h': '1 小时', '24h': '24 小时', '7d': '7 天' }, notes: { waiting: '等待指标样本', failedDatabase: '存在失败的数据库命令', serverErrors: '服务端错误率需要关注', slowQueries: '存在超过阈值的慢查询', healthy: '当前采样窗口内未见明显异常' },
|
||||
},
|
||||
api: {
|
||||
'data.constraint_conflict': '数据约束冲突。',
|
||||
'server.unhandled_error': '服务器处理请求时发生错误。',
|
||||
|
||||
Reference in new issue
Block a user