mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-08-30 12:45:32 +08:00
feat(admin): XHProf 性能日志五张表 Scheme 迁移与模型
This commit is contained in:
31
database/migrations/20260814100001_xhprof_run.php
Normal file
31
database/migrations/20260814100001_xhprof_run.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
|
||||
/**
|
||||
* XHProf 性能日志 - 采样记录表
|
||||
*
|
||||
* 每次被采样的请求一条记录。耗时字段库内统一微秒、内存统一字节,展示层换算。
|
||||
*/
|
||||
class XhprofRun extends Migrator
|
||||
{
|
||||
public function change()
|
||||
{
|
||||
$table = $this->table('xhprof_run', ['id' => false, 'primary_key' => ['id']])
|
||||
->setComment('XHProf 性能采样记录(每次请求一条)')
|
||||
->addColumn('id', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'identity' => true, 'comment' => '主键ID'])
|
||||
->addColumn('node_id', 'string', ['limit' => 64, 'null' => false, 'default' => 'default', 'comment' => '节点ID(区分不同采集节点)'])
|
||||
->addColumn('url', 'string', ['limit' => 500, 'null' => false, 'comment' => '请求完整 URL(超长截断)'])
|
||||
->addColumn('simple_url', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '规范化 URL(去 query、数字段替换,聚合用)'])
|
||||
->addColumn('method', 'string', ['limit' => 10, 'null' => false, 'default' => '', 'comment' => 'HTTP 方法'])
|
||||
->addColumn('wall_time', 'biginteger', ['default' => 0, 'comment' => '总耗时(微秒,main() 的 wt)'])
|
||||
->addColumn('cpu_time', 'biginteger', ['default' => 0, 'comment' => 'CPU 耗时(微秒,main() 的 cpu)'])
|
||||
->addColumn('memory_peak', 'biginteger', ['default' => 0, 'comment' => '内存峰值(字节,main() 的 pmu)'])
|
||||
->addColumn('request_time', 'decimal', ['precision' => 12, 'scale' => 3, 'default' => 0, 'comment' => '请求开始时间(REQUEST_TIME_FLOAT 浮点秒)'])
|
||||
->addColumn('create_time', 'integer', ['limit' => 11, 'comment' => '入库时间戳', 'signed' => false])
|
||||
->addIndex(['simple_url', 'request_time'], ['name' => 'idx_simple_url_time'])
|
||||
->addIndex(['request_time'], ['name' => 'idx_request_time'])
|
||||
->addIndex(['wall_time'], ['name' => 'idx_wall_time'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user