diff --git a/.gitignore b/.gitignore index 427fe68..4fde07c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ parity-reports/ .DS_Store # C3 卫生:可再生噪声(2026-06-13) +# 运行时日志(logback 滚动文件;§10.2 可观测性) +logs/ __pycache__/ *.pyc /data/ diff --git a/docs/项目进度与路线-总览-2026-06-21.md b/docs/项目进度与路线-总览-2026-06-21.md index 0acfd10..cfaf1d3 100644 --- a/docs/项目进度与路线-总览-2026-06-21.md +++ b/docs/项目进度与路线-总览-2026-06-21.md @@ -189,7 +189,7 @@ EIP3(Vaadin / 老引擎)→ EIP4(amis 前端 + 保真层 + 转换器)迁 **【生产交付能力 — 意图与实现最大成体系缺口,对应 A10】** - **Flyway 平台表迁移未实现 · medium · L**:`架构设计.md:36` 承诺 Flyway,全仓零命中;SYS_* 建表散落 bootstrap/`*_upsert.sql`/CLI 内嵌(`bootstrap-ai-agent.sql` 两份易漂移)。→ 引入 Flyway 收敛为 `V{n}__*.sql` 单一真相。 - **4 进程交付无 compose/Dockerfile/Nginx 配置 · medium · L**:`find docker-compose*` 零命中,切流/回滚仅停留文档。→ 补 `deploy/`(compose 四服务 + 健康检查 + `nginx.conf` 切流 upstream + `.env.example`)。 -- **可观测性近零 · medium · M**:pom 无 actuator/micrometer,无健康端点,无 `logback-spring.xml`。→ 加 actuator `/health`(liveness/readiness)+ prod JSON 结构化日志。 +- **✅【已完成 2026-06-24】可观测性近零**:原状=无 actuator/无健康端点/无 logback 配置/base 日志 DEBUG(prod 继承会刷屏)。**已做**:① platform-app 加 `spring-boot-starter-actuator`,`management` 只暴露 `health`(`probes.enabled` 开 liveness/readiness,`show-details/components: when-authorized` 匿名不泄露 db 等组件细节)——不上 Prometheus 全家桶,守中间件最小化;② `SecurityConfig.PUBLIC_PATHS` 加 `/actuator/health(/**)`,prod 链探针免认证可达;③ 新增 `logback-spring.xml`(控制台 + 50MB×14 天滚动文件,文件 appender 仅 dev/local/prod 启用、不污染单测);④ base `application.yml` 的 `com.dsasp`/`jdbc.core` 日志 DEBUG→INFO(prod 继承 INFO,dev 仍 DEBUG)。**验证**:真启动 dev profile(1.7s 起)curl `/actuator/health`=`200 {"status":"UP","groups":["liveness","readiness"]}`、`/health/readiness`=200 UP、`/health/liveness`=200 UP;SecurityProfileTest 3/3 + ArchitectureRulesTest 6/6 无回归。**残留**:prod JSON 结构化日志需 Spring Boot 3.4 内建或 logstash-encoder 依赖,留作后续(避免现在加依赖)。 **【验证体系】** - **逐行对拍框架已冻结 · high · M**:`parity-reports/` 全是 `20260611` 时间戳,对拍 main 末次提交 0611,11 天引擎/转换器改动从未重拍;`--discover`/`--realprivilege` 从不在 CI 跑。→ 接夜间 job + 基线锁定(本次 vs 上次 diff,非 0 即阻断)。 diff --git a/platform-app/pom.xml b/platform-app/pom.xml index f2da973..a83ab95 100644 --- a/platform-app/pom.xml +++ b/platform-app/pom.xml @@ -20,6 +20,8 @@ com.eip4platform-converter com.eip4platform-ai org.springframework.bootspring-boot-starter-web + + org.springframework.bootspring-boot-starter-actuator org.postgresqlpostgresqlruntime org.springframework.bootspring-boot-starter-testtest diff --git a/platform-app/src/main/resources/application.yml b/platform-app/src/main/resources/application.yml index 842a3cc..edfe220 100644 --- a/platform-app/src/main/resources/application.yml +++ b/platform-app/src/main/resources/application.yml @@ -40,7 +40,22 @@ eip4: file: root: ${EIP4_FILE_ROOT:./data/files} +# 可观测性(总览 §10.2):只暴露 health(含 liveness/readiness 探针),不开 env/beans 等敏感端点。 +# 健康详情仅对已认证者可见(匿名探针只见 UP/DOWN,不泄露 db 等组件细节)。 +management: + endpoints: + web: + exposure: + include: health + endpoint: + health: + probes: + enabled: true + show-details: when-authorized + show-components: when-authorized + logging: level: - com.dsasp: DEBUG - org.springframework.jdbc.core: DEBUG + # base 默认 INFO(prod 无独立 profile 时继承此处,避免 DEBUG 刷屏);dev profile 覆盖为 DEBUG 调试 + com.dsasp: INFO + org.springframework.jdbc.core: INFO diff --git a/platform-app/src/main/resources/logback-spring.xml b/platform-app/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..658a208 --- /dev/null +++ b/platform-app/src/main/resources/logback-spring.xml @@ -0,0 +1,49 @@ + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + UTF-8 + + + + + ${LOG_FILE} + + ${FILE_LOG_PATTERN} + UTF-8 + + + ${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz + 50MB + 14 + 2GB + + + + + + + + + + + + + + + + + + diff --git a/platform-auth/src/main/java/com/eip4/platform/auth/security/SecurityConfig.java b/platform-auth/src/main/java/com/eip4/platform/auth/security/SecurityConfig.java index 2aeb3bc..41e2bb5 100644 --- a/platform-auth/src/main/java/com/eip4/platform/auth/security/SecurityConfig.java +++ b/platform-auth/src/main/java/com/eip4/platform/auth/security/SecurityConfig.java @@ -30,11 +30,12 @@ import org.springframework.security.web.util.matcher.AntPathRequestMatcher; @Configuration public class SecurityConfig { - /** 始终放行的路径:登录端点 + API 文档(认证前置依赖,不得拦)。 */ + /** 始终放行的路径:登录端点 + API 文档(认证前置依赖) + 健康探针(LB/k8s 探活,prod 亦免认证)。 */ static final String[] PUBLIC_PATHS = { "/api/auth/**", "/swagger-ui/**", "/swagger-ui.html", "/v3/api-docs/**", "/v3/api-docs.yaml", + "/actuator/health", "/actuator/health/**", }; private final JwtService jwtService;