feat(observability): add structured application logging
Emit correlated JSON logs from the API and FunASR services, propagate request IDs to the client, and configure bounded opt-in Docker logging. Document the host-wide Grafana/Loki query workflow and keep observability deployment ownership outside the application repository.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import {
|
||||
copyApiRequestId,
|
||||
createProfile,
|
||||
deleteProfile as deleteProfileRequest,
|
||||
getApiErrorMessage,
|
||||
getApiRequestId,
|
||||
getProfileDefaults,
|
||||
listFeedbackRecords,
|
||||
listProfiles
|
||||
@@ -107,7 +109,8 @@ Page({
|
||||
loading: false,
|
||||
saving: false,
|
||||
deletingId: '',
|
||||
errorMessage: ''
|
||||
errorMessage: '',
|
||||
errorRequestId: ''
|
||||
},
|
||||
|
||||
onShow() {
|
||||
@@ -119,7 +122,7 @@ Page({
|
||||
},
|
||||
|
||||
async refreshProfiles(showSuccess = false) {
|
||||
this.setData({ loading: true, errorMessage: '' })
|
||||
this.setData({ loading: true, errorMessage: '', errorRequestId: '' })
|
||||
try {
|
||||
const profiles = (await listProfiles()).map(withAcademicTermLabel)
|
||||
const filteredProfiles = filterProfiles(
|
||||
@@ -139,7 +142,7 @@ Page({
|
||||
})
|
||||
if (showSuccess) wx.showToast({ title: '档案已刷新', icon: 'success' })
|
||||
} catch (error) {
|
||||
this.setData({ errorMessage: getApiErrorMessage(error) })
|
||||
this.setData({ errorMessage: getApiErrorMessage(error), errorRequestId: getApiRequestId(error) })
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
@@ -153,6 +156,10 @@ Page({
|
||||
void this.refreshProfiles()
|
||||
},
|
||||
|
||||
copyRequestId() {
|
||||
copyApiRequestId(this.data.errorRequestId)
|
||||
},
|
||||
|
||||
onSearch(event: InputEvent) {
|
||||
const query = event.detail.value
|
||||
this.setData({
|
||||
|
||||
@@ -6,7 +6,13 @@
|
||||
<text class="page-subtitle">管理学生默认信息,用于快速生成课堂反馈</text>
|
||||
|
||||
<view wx:if="{{errorMessage}}" class="status-banner">
|
||||
<text>{{errorMessage}}</text>
|
||||
<view class="status-copy">
|
||||
<text>{{errorMessage}}</text>
|
||||
<view wx:if="{{errorRequestId}}" class="status-request-id">
|
||||
<text>请求编号:{{errorRequestId}}</text>
|
||||
<text class="status-action" bindtap="copyRequestId">复制</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="status-action" bindtap="retryLoad">重试</text>
|
||||
</view>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user