improve otel trace details and internal trans capture

This commit is contained in:
Codex
2026-06-21 16:51:50 +00:00
parent 06bffaf74a
commit a08dfea9da
2 changed files with 50 additions and 7 deletions
+10 -3
View File
@@ -8401,15 +8401,22 @@ ${tlsLines} @api path /health* /auth* /v1* /json-rpc* /openapi* /docs* /swagg
}
function runTransScript(node: string, script: string, input: string, timeoutSeconds: number): CommandResult {
return runCommand([transPath(), `${node}:k3s`, "sh", "--", script], repoRoot, { input, timeoutMs: timeoutSeconds * 1000 });
return runCommand([transPath(), `${node}:k3s`, "sh", "--", script], repoRoot, { input, timeoutMs: timeoutSeconds * 1000, env: internalTransCaptureEnv() });
}
function runTransHostScript(node: string, script: string, input: string, timeoutSeconds: number): CommandResult {
return runCommand([transPath(), node, "sh", "--", script], repoRoot, { input, timeoutMs: timeoutSeconds * 1000 });
return runCommand([transPath(), node, "sh", "--", script], repoRoot, { input, timeoutMs: timeoutSeconds * 1000, env: internalTransCaptureEnv() });
}
function runTransWorkspaceStdinScript(node: string, workspace: string, script: string, timeoutSeconds: number): CommandResult {
return runCommand([transPath(), `${node}:${workspace}`, "sh"], repoRoot, { input: script, timeoutMs: timeoutSeconds * 1000 });
return runCommand([transPath(), `${node}:${workspace}`, "sh"], repoRoot, { input: script, timeoutMs: timeoutSeconds * 1000, env: internalTransCaptureEnv() });
}
function internalTransCaptureEnv(): NodeJS.ProcessEnv {
return {
...process.env,
UNIDESK_SSH_STDOUT_STREAM_MAX_BYTES: "16777216",
};
}
function runObsoleteSecretCleanup(options: NodeSecretOptions, spec: RuntimeSecretSpec): Record<string, unknown> {
+40 -4
View File
@@ -877,19 +877,19 @@ function renderTraceResult(response: Record<string, unknown>): RenderedCliResult
if (errorSpans.length === 0) {
lines.push("-");
} else {
lines.push("SERVICE DURATION_MS NAME");
lines.push("SERVICE DURATION_MS NAME DETAIL");
for (const item of errorSpans.slice(0, 8)) {
const row = recordValue(item);
lines.push(`${pad(truncate(textValue(row.service) || "-", 23), 23)} ${pad(textValue(row.durationMs) || "-", 12)} ${truncate(textValue(row.name) || "-", 80)}`);
lines.push(`${pad(truncate(textValue(row.service) || "-", 23), 23)} ${pad(textValue(row.durationMs) || "-", 12)} ${pad(truncate(textValue(row.name) || "-", 40), 40)} ${truncate(traceSpanDetail(row), 96)}`);
}
}
if (matchedSpans.length > 0) {
lines.push("");
lines.push("MATCHED_SPANS");
lines.push("SERVICE DURATION_MS NAME");
lines.push("SERVICE DURATION_MS NAME DETAIL");
for (const item of matchedSpans.slice(0, 8)) {
const row = recordValue(item);
lines.push(`${pad(truncate(textValue(row.service) || "-", 23), 23)} ${pad(textValue(row.durationMs) || "-", 12)} ${truncate(textValue(row.name) || "-", 80)}`);
lines.push(`${pad(truncate(textValue(row.service) || "-", 23), 23)} ${pad(textValue(row.durationMs) || "-", 12)} ${pad(truncate(textValue(row.name) || "-", 40), 40)} ${truncate(traceSpanDetail(row), 96)}`);
}
}
lines.push("");
@@ -904,6 +904,36 @@ function renderTraceResult(response: Record<string, unknown>): RenderedCliResult
};
}
function traceSpanDetail(span: Record<string, unknown>): string {
const attrs = recordValue(span.attributes);
const parts: string[] = [];
for (const key of [
"failureKind",
"message",
"eventType",
"toolName",
"exitCode",
"durationMs",
"waitingFor",
"lastEventLabel",
"idleMs",
"idleSeconds",
"idleThresholdMs",
"lastEventAgeMs",
"terminalStatus",
"http.method",
"http.route",
"http.status_code",
"runId",
"commandId",
"runnerJobId",
]) {
const value = textValue(attrs[key]);
if (value) parts.push(`${key}=${value}`);
}
return parts.join(" ") || "-";
}
function recordValue(value: unknown): Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value) ? value as Record<string, unknown> : {};
}
@@ -1547,6 +1577,8 @@ IMPORTANT_ATTRS = [
"returnedEvents", "sinceSeq", "afterSeq", "limit", "fromSeq", "toSeq",
"totalEvents", "hasMore", "fullTraceLoaded", "rawEventCount",
"maxSeq", "traceLastSeq", "endSeq", "commandFiltered",
"waitingFor", "lastEventLabel", "idleMs", "idleSeconds", "idleThresholdMs",
"lastEventAgeMs", "toolName", "exitCode", "durationMs", "command",
"error", "error.message", "exception.type", "exception.message",
"valuesPrinted",
]
@@ -1789,6 +1821,8 @@ IMPORTANT_ATTRS = [
"returnedEvents", "sinceSeq", "afterSeq", "limit", "fromSeq", "toSeq",
"totalEvents", "hasMore", "fullTraceLoaded", "rawEventCount",
"maxSeq", "traceLastSeq", "endSeq", "commandFiltered",
"waitingFor", "lastEventLabel", "idleMs", "idleSeconds", "idleThresholdMs",
"lastEventAgeMs", "toolName", "exitCode", "durationMs", "command",
"error", "error.message", "exception.type", "exception.message",
"valuesPrinted",
]
@@ -2102,6 +2136,8 @@ IMPORTANT_ATTRS = [
"maxSeq", "traceLastSeq", "endSeq", "commandFiltered",
"seq", "eventSeq", "sourceSeq", "sourceLatestSeq", "latestSeq",
"lastSeq", "sourceEventCount", "projectedSeq", "lastProjectedSeq",
"waitingFor", "lastEventLabel", "idleMs", "idleSeconds", "idleThresholdMs",
"lastEventAgeMs", "toolName", "exitCode", "durationMs", "command",
"status", "turnStatus", "error", "error.message", "exception.type",
"exception.message", "valuesPrinted",
]