# Phase 7: 日志与可观测性 审计日期: 2026-05-04 ## 1. Service 层 tracing 总览 `crates/erp-health/src/service/` 中 tracing::info/warn/error 总计 **116 次**,分布在 17 个文件中。 分布明细(按文件): - lab_report (health_data_service): 16 - action_inbox_service: 14 - follow_up_service: 13 - vital_signs (health_data_service): 12 - health_record (health_data_service): 12 - consultation_service: 10 - relation (patient_service): 8 - crud (patient_service): 8 - tag (patient_service): 4 - seed: 4 - points_service/event: 2 - appointment_service: 2 - family_proxy_service: 3 - alert (health_data_service): 3 - critical_alert_service: 3 - alert_noise_reducer: 1 - device_reading_service: 1 ## 2. 新增 service 文件 tracing 覆盖 | 文件 | tracing 次数 | 状态 | |------|-------------|------| | action_inbox_service.rs | 14 | OK | | care_plan_service.rs | **0** | **缺失** | | shift_service.rs | **0** | **缺失** | | ble_gateway_service.rs | **0** | **缺失** | | family_proxy_service.rs | 3 | OK | | vital_signs_daily_service.rs | **0** | **缺失** | **4/6 新增 service 无任何 tracing 日志**。care_plan、shift、ble_gateway、vital_signs_daily 完全没有可观测性覆盖。 ## 3. 新增错误类型 ### OAuth Error 文件: `crates/erp-health/src/oauth/error.rs` 枚举 `OAuthError` 包含 7 个变体: InvalidClient, ClientInactive, InvalidScope, UnsupportedGrantType, RateLimitExceeded, ClientNotFound, DbError, HashError, JwtError。完整实现了 `From -> AppError` 和 `From -> OAuthError`。 ### FHIR Error **不存在**。整个 erp-health crate 中无 FHIR 相关错误类型定义。 ## 4. 建议 1. 为 care_plan_service、shift_service、ble_gateway_service、vital_signs_daily_service 补充关键操作的 tracing::info/error 2. 考虑引入 FHIR 错误类型(如需对接 FHIR 标准) 3. 建议在 service 层关键入口统一添加 tracing span