@lark-apaas/miaoda-cli 0.1.2-alpha.ae32290 → 0.1.2-alpha.b6d5335
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.
|
@@ -97,7 +97,7 @@ exports.errorJobSchema = {
|
|
|
97
97
|
columns: [
|
|
98
98
|
{ key: "jobID", label: "job-id" },
|
|
99
99
|
{ key: "componentName", label: "component" },
|
|
100
|
-
{ key: "errorMsg", label: "error"
|
|
100
|
+
{ key: "errorMsg", label: "error" },
|
|
101
101
|
],
|
|
102
102
|
strict: true,
|
|
103
103
|
};
|
|
@@ -23,8 +23,7 @@ function registerObservabilityCommands(program) {
|
|
|
23
23
|
应用上下文:--app-id <id> 或环境变量 MIAODA_APP_ID。
|
|
24
24
|
|
|
25
25
|
应用环境
|
|
26
|
-
|
|
27
|
-
metric/analytics 不需要 --env。
|
|
26
|
+
目前只支持线上环境。
|
|
28
27
|
`);
|
|
29
28
|
registerLog(obCmd);
|
|
30
29
|
registerTrace(obCmd);
|
|
@@ -161,7 +160,7 @@ function registerMetric(parent) {
|
|
|
161
160
|
.addOption(new commander_1.Option("--down-sample <duration>", "降采样粒度(1m=1分钟 / 1h=1小时 / 1d=1天,大小写不敏感)")
|
|
162
161
|
.choices(["1m", "1h", "1d"])
|
|
163
162
|
.argParser((0, shared_1.caseInsensitiveChoice)(["1m", "1h", "1d"]))
|
|
164
|
-
.default("
|
|
163
|
+
.default("1m"))
|
|
165
164
|
.addHelpText("after", `${COMMON_TIME_HELP}
|
|
166
165
|
JSON 输出
|
|
167
166
|
{"data": [{"metricName": "...", "dimensions": {...}, "dataPoints": [...]}], "next_cursor": null, "has_more": false}
|
|
@@ -71,7 +71,7 @@ async function handleObservabilityMetric(opts) {
|
|
|
71
71
|
]);
|
|
72
72
|
// since/until 直接以秒透传到 BAM;当前未做桶对齐(如需开启把 until
|
|
73
73
|
// 用 ceilMsToBucket(untilMs, downSample as GranularityBucket) 包一层即可)。
|
|
74
|
-
const downSample = opts.downSample ?? "
|
|
74
|
+
const downSample = opts.downSample ?? "1m";
|
|
75
75
|
const nowMs = Date.now();
|
|
76
76
|
const sinceMs = (0, helpers_1.parseToMs)(opts.since) ?? nowMs - 30 * 86_400_000;
|
|
77
77
|
const untilMs = (0, helpers_1.parseToMs)(opts.until) ?? nowMs;
|
package/dist/utils/http.js
CHANGED
|
@@ -73,14 +73,28 @@ function applyCanaryHeader(reqConfig) {
|
|
|
73
73
|
/** 走管理端 innerapi 的 POST + 信封解析 */
|
|
74
74
|
async function postInnerApi(url, body, opts) {
|
|
75
75
|
const startMs = logRequestStart("POST", url, body);
|
|
76
|
-
|
|
76
|
+
let response;
|
|
77
|
+
try {
|
|
78
|
+
response = await getHttpClient().post(url, body);
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
logResponseFailure("POST", url, err, startMs);
|
|
82
|
+
throw err;
|
|
83
|
+
}
|
|
77
84
|
logResponseEnd("POST", url, response, startMs);
|
|
78
85
|
return handleInnerEnvelope(response, url, opts);
|
|
79
86
|
}
|
|
80
87
|
/** 走管理端 innerapi 的 GET + 信封解析 */
|
|
81
88
|
async function getInnerApi(url, opts) {
|
|
82
89
|
const startMs = logRequestStart("GET", url);
|
|
83
|
-
|
|
90
|
+
let response;
|
|
91
|
+
try {
|
|
92
|
+
response = await getHttpClient().get(url);
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
logResponseFailure("GET", url, err, startMs);
|
|
96
|
+
throw err;
|
|
97
|
+
}
|
|
84
98
|
logResponseEnd("GET", url, response, startMs);
|
|
85
99
|
return handleInnerEnvelope(response, url, opts);
|
|
86
100
|
}
|
|
@@ -131,6 +145,24 @@ function logResponseEnd(method, url, response, startMs) {
|
|
|
131
145
|
const tail = logid ? ` logid=${logid}` : "";
|
|
132
146
|
(0, logger_1.debug)(`← ${method} ${url} ${String(response.status)} ${String(elapsedMs)}ms${tail}`);
|
|
133
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* http-client 在 4xx/5xx / 网络错误时直接 reject(不返回 Response);
|
|
150
|
+
* 这条路径下 logResponseEnd 不会跑——这里专门补一行,尽可能从 HttpError
|
|
151
|
+
* 上抠出 status / logid,让 verbose 仍能看到失败请求的关键信息。
|
|
152
|
+
*/
|
|
153
|
+
function logResponseFailure(method, url, err, startMs) {
|
|
154
|
+
if (!(0, config_1.getConfig)().verbose)
|
|
155
|
+
return;
|
|
156
|
+
const elapsedMs = Date.now() - startMs;
|
|
157
|
+
// @lark-apaas/http-client 的 HttpError.response: Response | undefined
|
|
158
|
+
const e = err;
|
|
159
|
+
const status = e.response?.status;
|
|
160
|
+
const logid = e.response?.headers ? pickLogid(e.response.headers) : null;
|
|
161
|
+
const statusPart = status !== undefined ? String(status) : "ERR";
|
|
162
|
+
const logidPart = logid ? ` logid=${logid}` : "";
|
|
163
|
+
const msgPart = e.message ? ` (${e.message})` : "";
|
|
164
|
+
(0, logger_1.debug)(`✗ ${method} ${url} ${statusPart} ${String(elapsedMs)}ms${logidPart}${msgPart}`);
|
|
165
|
+
}
|
|
134
166
|
/** BAM gateway 在不同 PSM/版本上 logid 落在不同 header;按命中顺序取第一个非空。 */
|
|
135
167
|
function pickLogid(headers) {
|
|
136
168
|
return (headers.get("x-tt-logid") ??
|