bfi-cli 0.1.109 → 0.1.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +64 -9
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -8992,7 +8992,8 @@ const ALLOWED_FLAGS = {
|
|
|
8992
8992
|
"--app",
|
|
8993
8993
|
"--no-profiler",
|
|
8994
8994
|
"--page",
|
|
8995
|
-
"--page-size"
|
|
8995
|
+
"--page-size",
|
|
8996
|
+
"--timeout"
|
|
8996
8997
|
],
|
|
8997
8998
|
slowcall: [
|
|
8998
8999
|
...F_ENV,
|
|
@@ -9003,7 +9004,8 @@ const ALLOWED_FLAGS = {
|
|
|
9003
9004
|
"--profiler",
|
|
9004
9005
|
"--min-cost",
|
|
9005
9006
|
"--page",
|
|
9006
|
-
"--page-size"
|
|
9007
|
+
"--page-size",
|
|
9008
|
+
"--timeout"
|
|
9007
9009
|
],
|
|
9008
9010
|
exceptions: [
|
|
9009
9011
|
...F_ENV,
|
|
@@ -9144,6 +9146,43 @@ function timeOpts(args) {
|
|
|
9144
9146
|
if (et) out.end_time = et;
|
|
9145
9147
|
return out;
|
|
9146
9148
|
}
|
|
9149
|
+
function slowQueryTimeoutMs(args) {
|
|
9150
|
+
const raw = opt(args, "--timeout");
|
|
9151
|
+
if (raw === void 0) return 15e4;
|
|
9152
|
+
const sec = Number(raw);
|
|
9153
|
+
if (!Number.isFinite(sec) || sec <= 0) {
|
|
9154
|
+
console.error(`--timeout 非法:${raw}(应为正数秒,如 180)`);
|
|
9155
|
+
process.exit(1);
|
|
9156
|
+
}
|
|
9157
|
+
return sec * 1e3;
|
|
9158
|
+
}
|
|
9159
|
+
function windowDays(args) {
|
|
9160
|
+
const t = opt(args, "-t", "--time");
|
|
9161
|
+
if (t) {
|
|
9162
|
+
const m = /^(\d+)([mhdw])$/.exec(t);
|
|
9163
|
+
if (!m) return 0;
|
|
9164
|
+
const n = Number(m[1]);
|
|
9165
|
+
const unit = m[2];
|
|
9166
|
+
if (unit === "w") return n * 7;
|
|
9167
|
+
if (unit === "d") return n;
|
|
9168
|
+
if (unit === "h") return n / 24;
|
|
9169
|
+
return n / 1440;
|
|
9170
|
+
}
|
|
9171
|
+
const st = opt(args, "--start-time");
|
|
9172
|
+
const et = opt(args, "--end-time");
|
|
9173
|
+
if (st && et) {
|
|
9174
|
+
const ms = Date.parse(et.replace(" ", "T")) - Date.parse(st.replace(" ", "T"));
|
|
9175
|
+
return Number.isFinite(ms) ? ms / 864e5 : 0;
|
|
9176
|
+
}
|
|
9177
|
+
return 0;
|
|
9178
|
+
}
|
|
9179
|
+
function warnWideQuery(label, args, pageSize, narrowFlags) {
|
|
9180
|
+
if (narrowFlags.some((f) => opt(args, f))) return;
|
|
9181
|
+
const days = windowDays(args);
|
|
9182
|
+
if (days < 1 && pageSize <= 200) return;
|
|
9183
|
+
const win = days ? `窗口 ${days.toFixed(1)} 天` : "窗口未识别";
|
|
9184
|
+
console.error(`⚠️ ${label} ${win} / pageSize ${pageSize} 且未限定服务:上游模糊匹配 + 全服务扫描,易触发 120s 超时;建议加 --app <appCode> 或缩短 -t(≤6h)`);
|
|
9185
|
+
}
|
|
9147
9186
|
function requireToken(api) {
|
|
9148
9187
|
if (!api.token) {
|
|
9149
9188
|
console.error("未认证。先运行:bfi auth login --token <sk-token>(或传 --token)");
|
|
@@ -9354,7 +9393,12 @@ async function runYmc(args, globalOpts) {
|
|
|
9354
9393
|
const v = opt(rest, name);
|
|
9355
9394
|
if (v) body[k] = v;
|
|
9356
9395
|
}
|
|
9357
|
-
|
|
9396
|
+
warnWideQuery("慢 SQL", rest, Number(body.pageSize), [
|
|
9397
|
+
"--app",
|
|
9398
|
+
"--trace-id",
|
|
9399
|
+
"--md5"
|
|
9400
|
+
]);
|
|
9401
|
+
emit(await api.call("ymc/warningSql", body, slowQueryTimeoutMs(rest)), jsonMode, (data) => {
|
|
9358
9402
|
const d = data;
|
|
9359
9403
|
const rows = Array.isArray(d) ? d : d.rows ?? d.data ?? [];
|
|
9360
9404
|
const n = rows.length;
|
|
@@ -9388,7 +9432,12 @@ async function runYmc(args, globalOpts) {
|
|
|
9388
9432
|
const cost = opt(rest, "--min-cost");
|
|
9389
9433
|
if (cost) body.costTime = [Number(cost), 999999];
|
|
9390
9434
|
if (flag(rest, "--profiler")) console.error("⚠️ --profiler 是上游采样过滤器,实测常返回空集——常规取证请去掉(CPU 热点走 dump-list)");
|
|
9391
|
-
|
|
9435
|
+
warnWideQuery("慢调用", rest, Number(body.pageSize), [
|
|
9436
|
+
"--app",
|
|
9437
|
+
"--trace-id",
|
|
9438
|
+
"--method"
|
|
9439
|
+
]);
|
|
9440
|
+
emit(await api.call("ymc/warningCall", body, slowQueryTimeoutMs(rest)), jsonMode, (data) => {
|
|
9392
9441
|
const d = data;
|
|
9393
9442
|
const rows = Array.isArray(d) ? d : d.rows ?? d.data ?? [];
|
|
9394
9443
|
const n = rows.length;
|
|
@@ -9753,27 +9802,33 @@ const HELP = {
|
|
|
9753
9802
|
⚠️ 关键词按「整值」匹配:类名/全限定异常名必须整串加引号
|
|
9754
9803
|
("java.lang.OutOfMemoryError" 命中;简写 "OutOfMemoryError" 恒 0 命中且不报错)——sls-discipline §3
|
|
9755
9804
|
--app <appCode> 裸微服务名,前置 applicationname 限定(不限服务的检索会命中不相干服务)`,
|
|
9756
|
-
slowsql: `bfi ymc slowsql -t <time> -e <env> [--sql-str <表名或片段>] [--md5 <指纹>] [--trace-id <id>] [--app <appCode>] [--no-profiler] [--page N] [--page-size N] [--json]
|
|
9805
|
+
slowsql: `bfi ymc slowsql -t <time> -e <env> [--sql-str <表名或片段>] [--md5 <指纹>] [--trace-id <id>] [--app <appCode>] [--no-profiler] [--page N] [--page-size N] [--timeout <秒>] [--json]
|
|
9757
9806
|
慢 SQL 告警明细(耗时降序;摘要含 服务/耗时/行数/SQL 前段/指纹/调用栈首帧)。
|
|
9758
9807
|
参数:
|
|
9759
9808
|
-t <time> 时间窗(必填语义,服务端强校验)
|
|
9760
|
-
--sql-str 按 SQL
|
|
9761
|
-
--md5 按 SQL MD5 指纹精确过滤(同类 SQL
|
|
9809
|
+
--sql-str 按 SQL 片段过滤(表名/语句片段;模糊匹配,开销大,见下方警示)
|
|
9810
|
+
--md5 按 SQL MD5 指纹精确过滤(同类 SQL 归类;有指纹时优先用,毫秒级)
|
|
9762
9811
|
--trace-id 按链路过滤。⚠️ 按 trace 查询时不带 --app(traceId 已唯一限定,
|
|
9763
9812
|
--app 会截断其他服务的告警行——慢 SQL 归属哪个服务事先未知)
|
|
9764
9813
|
--app 服务维度过滤(无 traceId 时必带,裸 appCode)
|
|
9814
|
+
--page-size N 每页条数(服务端上限 200,超限直接报错并提示分页)
|
|
9815
|
+
--timeout <秒> 客户端超时(默认 150s;服务端上游超时 120s,留余量先拿服务端消息)
|
|
9765
9816
|
--no-profiler 显式关闭 enableProfiler(默认自动带 'true'——不带该字段上游 500,
|
|
9766
|
-
带了才返回 sqlStack
|
|
9817
|
+
带了才返回 sqlStack 调用栈;不需要调用栈时关闭约省 40% 耗时)
|
|
9818
|
+
⚠️ --sql-str 是模糊匹配:大窗口(≥1d)必须配 --app,否则上游全服务扫描极易 120s 超时
|
|
9819
|
+
(实测 10d 无 --app 必超时;同条件加 --app 后 ~105s 成功)。窗口优先 ≤6h。
|
|
9767
9820
|
示例:
|
|
9768
9821
|
bfi ymc slowsql -t 1d --app yonbip-scm-scmmp -e core3 # 服务维度(SQL 画像)
|
|
9769
9822
|
bfi ymc slowsql -t 1d --trace-id abc -e core3 # 链路维度(勿带 --app)`,
|
|
9770
|
-
slowcall: `bfi ymc slowcall -t <time> -e <env> [--trace-id <id>] [--app <appCode>] [--method <方法>] [--min-cost <ms>] [--page N] [--page-size N] [--json]
|
|
9823
|
+
slowcall: `bfi ymc slowcall -t <time> -e <env> [--trace-id <id>] [--app <appCode>] [--method <方法>] [--min-cost <ms>] [--page N] [--page-size N] [--timeout <秒>] [--json]
|
|
9771
9824
|
慢调用告警明细(耗时降序;摘要含 服务/耗时/sql/rpc/redis 分解/方法/pod)。
|
|
9772
9825
|
参数:
|
|
9773
9826
|
--trace-id 按链路过滤。⚠️ 不带 --app(同 slowsql,--app 会截断下游服务告警行)
|
|
9774
9827
|
--app 服务维度过滤(裸 appCode)
|
|
9775
9828
|
--method 按调用方法过滤
|
|
9776
9829
|
--min-cost <ms> 最小耗时过滤(body.costTime=[ms, 999999])
|
|
9830
|
+
--page-size N 每页条数(服务端上限 200,超限直接报错并提示分页)
|
|
9831
|
+
--timeout <秒> 客户端超时(默认 150s)
|
|
9777
9832
|
--profiler 透传上游 enableProfiler(仅返回有 CPU 采样记录的调用);
|
|
9778
9833
|
该过滤器常返回空集,常规取证勿带,CPU 热点走 dump-list。
|
|
9779
9834
|
示例:
|