Files
ulthon_admin/source/docs/xhprof-backend-verification-report.html

117 lines
12 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>XHProf 后台化验证报告Task 9 全链路验证与存证)</title>
<style>
body { font-family: "Microsoft YaHei", "Segoe UI", sans-serif; margin: 24px auto; max-width: 1100px; color: #333; line-height: 1.6; }
h1 { font-size: 22px; border-bottom: 2px solid #16baaa; padding-bottom: 8px; }
h2 { font-size: 17px; margin-top: 28px; color: #16a;
border-left: 4px solid #16baaa; padding-left: 10px; }
table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 13px; }
th, td { border: 1px solid #ddd; padding: 6px 10px; text-align: left; vertical-align: top; }
th { background: #f2fafa; }
.pass { color: #0a9463; font-weight: bold; }
.fail { color: #d43f3f; font-weight: bold; }
.warn { color: #c47b00; font-weight: bold; }
code, pre { font-family: Consolas, monospace; background: #f6f6f6; font-size: 12px; }
pre { padding: 10px; overflow-x: auto; border: 1px solid #e5e5e5; }
.shots img { max-width: 100%; border: 1px solid #ccc; margin: 6px 0; display: block; }
.shots figcaption { font-size: 12px; color: #666; margin-bottom: 14px; }
.meta { color: #666; font-size: 13px; }
</style>
</head>
<body>
<h1>XHProf 后台化验证报告</h1>
<p class="meta">计划:.omo/plans/xhprof-log-backend.md Task 9Wave 5 终验)<br>
环境docker-dev Windows 宿主 + docker composeulthon_admin:8000 / mysql:13306<br>
执行时间2026-08-14 23:30 ~ 2026-08-15 10:45Asia/Shanghai<br>
执行身份Sisyphus-Junior验证 + 一处 T7 缺陷修复)</p>
<h2>一、主链断言6 组,全部通过)</h2>
<table>
<tr><th>#</th><th>断言</th><th>实测结果</th><th>判定</th></tr>
<tr><td>1</td><td>XHPROF_ENABLE=true 重启栈(无 profile xhgui 容器</td><td>compose ps 4 服务mysql/redis/phpmyadmin/ulthon_admindocker ps -a xhgui/xhprof 容器;容器内 env XHPROF_ENABLE=true。注:旧 xhgui 残留容器需带 --profile xhgui down 才会移除compose down 不动非激活 profile 的容器,符合预期语义)</td><td class="pass">PASS</td></tr>
<tr><td>2</td><td>5 _profiler=1 请求curl -b当天 jsonl 行数=5</td><td>5 请求全 200runs-20260815.jsonl wc -l=55 行均含 "profile"+"meta" 键,末字节 \n请求后立即 wc 曾见 4,系 fastcgi 响应先于 shutdown 落盘的毫秒级窗口1 秒后补齐)</td><td class="pass">PASS</td></tr>
<tr><td>3</td><td>导入后 run/detail +5,导完 jsonl 删除</td><td>timer 自动轮ul_system_timer_log id=755)抢先导入:{"files":1,"runs":5,"watches":10,"fails":0,"deleted":1}run 12→17+5node_id=d804e1bd9e6d-ac4562f2detail 12→17+5xhprof 目录空(文件已删)</td><td class="pass">PASS</td></tr>
<tr><td>4</td><td>watch 命中数 &gt;0 SQL 执行层规则 wt_sum &gt; 0</td><td>启用规则命中 26 watch_id=2SQL 执行层regex 实测 hex=7E7468696E6B5C5C64625C5C50444F436F6E6E656374696F6E3A3A2E2A7E ~think\\db\\PDOConnection::.*~12 命中 wt_sum=5554063uswatch_id=3 业务层控制器 2 命中watch_id=4 数据保存 12 命中</td><td class="pass">PASS</td></tr>
<tr><td>5</td><td>四页面 200:列表无添加钮 / 详情含 main() / watch 3 / 命中记录</td><td>xhprof.run/index 200 code=0(视图 toolbar:[]data-auth index/detaildetail?id=20 200 响应含 "fn": "main()"xhprof.watch/index 200 count=3xhprof.run_watch/index 200 count=33</td><td class="pass">PASS</td></tr>
<tr><td>6</td><td>清理dry-run 统计 真跑 过期=0 未过期不动xhgui_results 不变Must-NOT</td><td> 31 天前种子id 900001/900002 detail+run_watchdry-run {"run_watch_deleted":2,"detail_deleted":2,"run_deleted":2,"dry_run":true};真跑同计数 dry_run:false;过期行全 0;未过期 17 条原样xhgui_results 全程恒 27</td><td class="pass">PASS</td></tr>
</table>
<h2>二、失败路径4 条,全部通过)</h2>
<table>
<tr><th>#</th><th>场景</th><th>实测结果</th><th>判定</th></tr>
<tr><td>F1</td><td> JSON 行导入</td><td>追加非 JSON 文本行 导入 {"runs":1,"watches":2,"fails":1}:好行入库、坏行 fails+1 不中断</td><td class="pass">PASS</td></tr>
<tr><td>F2</td><td>无换行半行</td><td>追加无换行半行 导入 runs=0(不入库);补齐剩余片段+换行 导入 runs=1run 900005 wall_time=4321 与合成值精确一致;文件导完删除</td><td class="pass">PASS</td></tr>
<tr><td>F3</td><td>非法正则被拒</td><td>POST add 提交无定界符 think\db {"code":500,"msg":"正则非法(必须带定界符..."}DB T9-invalid </td><td class="pass">PASS</td></tr>
<tr><td>F4</td><td>禁用规则不物化</td><td> status=0 合法规则 T9-disabled-probe 采集+导入runs=2 watches=4 均来自启用规则)→ 该规则 run_watch 0 行;对照组启用规则各 +2 命中。验证后已删探针规则</td><td class="pass">PASS</td></tr>
</table>
<h2>三、回归3 + 终态恢复,全部通过)</h2>
<table>
<tr><th>#</th><th>场景</th><th>实测结果</th><th>判定</th></tr>
<tr><td>R1</td><td>XHPROF_ENABLE=false 静默</td><td>shell env false 重建容器env 确认)→ 5 次普通请求 + 3 _profiler=1 cookie 强制请求全 200jsonl 目录无文件(总闸拦截 cookie 强制)</td><td class="pass">PASS</td></tr>
<tr><td>R2</td><td> xhprof 报错</td><td>ul_debug_log 近期 error 0 条(含 xhprof 关键字 0 tools:log:show 尾部仅常规 SQL 日志</td><td class="pass">PASS</td></tr>
<tr><td>R3</td><td>4 stack compose config</td><td>docker-dev / docker-dev-sync / docker-serve / full 四个 docker-compose.yaml config -q 全部 OK</td><td class="pass">PASS</td></tr>
<tr><td>R4</td><td>终态恢复</td><td>XHPROF_ENABLE=true 重建容器 _profiler=1 请求 jsonl 1 手动导入 runs=1 watches=2 文件删除,采集闭环恢复;.env 无临时改动(全程 shell 环境变量传值)</td><td class="pass">PASS</td></tr>
</table>
<h2>四、页面 QAulthon-page-qa checklist两分辨率</h2>
<table>
<tr><th>检查项</th><th>采样列表</th><th>运行详情</th></tr>
<tr><td>页面可开HTML</td><td class="pass">OKiframe 200</td><td class="pass">OKiframe 200</td></tr>
<tr><td>数据正确</td><td class="pass">表头 8 列齐全(请求时间/方法/URL/节点/总耗时/CPU耗时/内存峰值/操作),共 23 </td><td class="pass">头部统计渲染(总耗时/CPU/SQL占比/内存峰值/请求信息)</td></tr>
<tr><td>按钮显隐data-auth</td><td class="pass">toolbar 0 按钮(无添加,符合只读设计);操作列仅"详情"data-auth-index/detailindex.html add 标记)</td><td class="pass">无多余按钮</td></tr>
<tr><td>搜索</td><td class="pass">搜索区由 cols 生成request_time range / method 等)</td><td>-(详情页无搜索)</td></tr>
<tr><td>1920x1080 布局</td><td class="pass">正常,操作列 fixed right</td><td class="pass">正常(弹层全屏)</td></tr>
<tr><td>390x844 布局</td><td class="pass">不崩:表格横向滚动形态,数据行/分页/fixed 操作列完整(框架在此视口走横向滚动而非卡片)</td><td class="pass">不崩:头部统计纵向堆叠可读</td></tr>
</table>
<p>命中记录页修复后32 行可见,时间列 2026-08-15 08:23:49 格式正确超阈值红色徽章685.844 ms 超阈值 500ms正常console 0 errors。监控规则页3 条预置规则 + regex 原文完整展示。</p>
<h2>五、验证中发现并处理的缺陷</h2>
<table>
<tr><th>#</th><th>缺陷</th><th>处置</th></tr>
<tr><td>B1已修复</td><td>app/admin/view/xhprof/run_watch/index.js:26 调用 window.UA_CORE.util.toDateString —— UA_CORE 全项目零定义T7 笔误 API浏览器抛 "Cannot read properties of undefined (reading 'util')",命中记录页数据行渲染崩溃</td><td class="pass">照抄 T5 formatRequestTime JS 实现替换(保留 isNaN 兜底);实测 32 行正常渲染、console 0 errorfix 提交入库</td></tr>
<tr><td>B2已修复</td><td>app/admin/view/xhprof/run/detail.js $.ajax 用裸相对 URL 'xhprof.run/detail',相对地址的解析基准是"当前 URL 目录":详情页自身位于 /admin/xhprof.run/detail基准目录 /admin/xhprof.run/),拼出 /admin/xhprof.run/xhprof.run/detail 404,函数表与 SQL 摘要在浏览器端加载失败服务端渲染的头部统计正常API 层功能本身正常)</td><td class="pass">改为 url: location.pathname + location.search当前页 URL 即同体 API 端点,对后台入口自定义改名免疫),并删除 data:{id}id 已在 query 中防重复拼接);弹层与非弹层两上下文实测:函数表 Top100 加载(函数总数 568main() 在列、SQL 摘要条有值1.17s / 16.76% / 90 函数 / 138 、console 0 errorfix 提交入库</td></tr>
</table>
<h2>六、关键命令与输出摘录</h2>
<pre># 断言1重启PowerShell env 传值)
$env:XHPROF_ENABLE='true'; docker compose -f source/stack/docker-dev/docker-compose.yaml up -d
docker compose ps --format "{{.Name}} {{.Service}}" # 4 服务,无 xhgui
# 断言25 次强制采集(容器内)
for i in 1 2 3 4 5; do curl -s -b "_profiler=1" -o /dev/null -w "%{http_code}\n" http://127.0.0.1:8000/; done
wc -l /var/www/html/runtime/xhprof/runs-20260815.jsonl # 5
# 断言3timer 自动导入抢先(手动 /do 返回 files:0 因已被消费)
SELECT result FROM ul_system_timer_log WHERE id=755;
# {"files":1,"runs":5,"watches":10,"fails":0,"deleted":1,"errors":[]}
# 断言6清理防刷 query nonce& 必须整体引号内,否则 PS/CRT 吃引号后 sh 将其后台化)
curl -s -X POST "http://127.0.0.1:8000/tools/timer.XhprofRunClean/do?nonce=t9dryA&dryRun=1"
# {"run_watch_deleted":2,"detail_deleted":2,"run_deleted":2,"dry_run":true}
curl -s -X POST "http://127.0.0.1:8000/tools/timer.XhprofRunClean/do?nonce=t9realC"
# {"run_watch_deleted":2,"detail_deleted":2,"run_deleted":2,"dry_run":false}
# 回归 R1false 总闸(连 cookie 强制也拦)
$env:XHPROF_ENABLE='false'; docker compose ... up -d # 8 请求全 200jsonl 不生成</pre>
<h2>七、截图存证6 1920x1080 + 390x844</h2>
<div class="shots">
<figure><img src="../../runtime/agents/xhprof-backend-screenshots/01-run-index-1920.png" alt="采样列表 1920"><figcaption>01 采样列表1920x1080 23 条,无添加按钮)</figcaption></figure>
<figure><img src="../../runtime/agents/xhprof-backend-screenshots/02-run-detail-1920.png" alt="运行详情 1920"><figcaption>02 运行详情1920x1080B2 修复后:函数表 Top100 加载、SQL 摘要有值、main() 在列)</figcaption></figure>
<figure><img src="../../runtime/agents/xhprof-backend-screenshots/03-watch-index-1920.png" alt="监控规则 1920"><figcaption>03 监控规则1920x10803 条预置规则)</figcaption></figure>
<figure><img src="../../runtime/agents/xhprof-backend-screenshots/04-run-watch-index-1920.png" alt="命中记录 1920"><figcaption>04 命中记录1920x1080B1 修复后 32 行正常渲染 + 超阈值徽章)</figcaption></figure>
<figure><img src="../../runtime/agents/xhprof-backend-screenshots/05-run-index-390.png" alt="采样列表 390"><figcaption>05 采样列表390x844横向滚动不崩</figcaption></figure>
<figure><img src="../../runtime/agents/xhprof-backend-screenshots/06-run-detail-390.png" alt="运行详情 390"><figcaption>06 运行详情390x844B2 修复后:函数表加载、统计卡片纵向堆叠不崩)</figcaption></figure>
</div>
<h2>八、结论</h2>
<p>6 组主链断言 + 4 条失败路径 + 3 条回归(+终态恢复)全部通过;页面 QA 两分辨率不崩。XHProf 后台化全链路(采集 jsonl 落盘 定时导入入库 watch 物化 后台三页面 过期清理在真实容器环境验证可用。T9 期间发现的两处前端缺陷B1 命中记录页假 API、B2 详情页相对路径 404)均已修复并浏览器实测通过,无遗留问题。</p>
</body>
</html>