mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-09-05 07:15:31 +08:00
feat(admin): XHProf 函数监控规则与命中记录
This commit is contained in:
62
app/admin/view/xhprof/run_watch/index.js
Normal file
62
app/admin/view/xhprof/run_watch/index.js
Normal file
@@ -0,0 +1,62 @@
|
||||
$(function(){
|
||||
ua.table.render({
|
||||
init: init,
|
||||
toolbar: [],
|
||||
defaultToolbar: ['filter'],
|
||||
cols: [[
|
||||
{field: 'id', title: 'ID', width: 80, sort: true},
|
||||
{field: 'watch_id', title: '监控规则', width: 160, search: 'select', searchOp: '=', selectList: ua.getDataBrage('select_list_watch'), templet: function(d) {
|
||||
return d.watch && d.watch.name ? d.watch.name : ('#' + d.watch_id);
|
||||
}},
|
||||
{field: 'run.url', title: '请求 URL', minWidth: 220, search: false, templet: function(d) {
|
||||
if (!d.run || !d.run.url) {
|
||||
return '<span class="layui-text-em">#' + d.run_id + '</span>';
|
||||
}
|
||||
var esc = String(d.run.url).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
return '<span title="' + esc + '">' + esc + '</span>';
|
||||
}},
|
||||
{field: 'run.request_time', title: '请求时间', width: 170, search: 'range', templet: function(d) {
|
||||
if (!d.run || !d.run.request_time) {
|
||||
return '-';
|
||||
}
|
||||
var ts = parseFloat(d.run.request_time);
|
||||
if (isNaN(ts) || ts <= 0) {
|
||||
return '-';
|
||||
}
|
||||
return window.UA_CORE.util.toDateString(ts * 1000, 'yyyy-MM-dd HH:mm:ss');
|
||||
}},
|
||||
{field: 'ct', title: '命中次数', width: 100, search: 'number_limit'},
|
||||
{field: 'wt_sum', title: '耗时合计(ms)', width: 140, search: 'number_limit', templet: function(d) {
|
||||
var ms = parseFloat(d.wt_sum) / 1000;
|
||||
var threshold = d.watch ? parseInt(d.watch.threshold_ms, 10) : 0;
|
||||
var text = (isNaN(ms) ? 0 : ms).toFixed(3) + ' ms';
|
||||
if (threshold > 0 && ms > threshold) {
|
||||
return '<span class="layui-badge layui-bg-red">' + text + '(超阈值 ' + threshold + 'ms)</span>';
|
||||
}
|
||||
return text;
|
||||
}},
|
||||
{field: 'wt_max', title: '单次最大(ms)', width: 130, search: 'number_limit', templet: function(d) {
|
||||
var ms = parseFloat(d.wt_max) / 1000;
|
||||
return (isNaN(ms) ? 0 : ms).toFixed(3) + ' ms';
|
||||
}},
|
||||
{field: 'create_time', title: '入库时间', width: 170, search: false, templet: ua.table.date},
|
||||
{
|
||||
width: 100, title: '操作', templet: ua.table.tool, fixed: 'right', operat: [
|
||||
[{
|
||||
class: 'layui-btn layui-btn-primary layui-btn-xs',
|
||||
method: 'tab',
|
||||
field: 'id',
|
||||
text: '详情',
|
||||
title: '查看详情',
|
||||
auth: 'read',
|
||||
url: init.readUrl,
|
||||
icon: ''
|
||||
}]
|
||||
]
|
||||
},
|
||||
|
||||
]],
|
||||
});
|
||||
|
||||
ua.listen();
|
||||
})
|
||||
Reference in New Issue
Block a user