fix(otel): expose workbench resource timing columns (#713)

Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
Lyon
2026-06-23 02:06:43 +08:00
committed by GitHub
parent 619c630ae5
commit 23b4ecbf09
+23 -4
View File
@@ -825,10 +825,19 @@ function renderTraceTable(input: {
const spanRows = uniqueSpanRecords(spanSource)
.slice(0, 10)
.map((span) => {
const attrs = asPlainRecord(span.attributes);
return [
shortenEnd(textValue(span.name), 48),
shortenEnd(textValue(span.service), 28),
spanDetail(span, 360),
shortenEnd(textValue(span.name), 40),
shortenEnd(textValue(span.service), 22),
shortenEnd(spanColumnAttr(attrs, ["http.route", "workbench.ui.route"]), 34),
spanColumnAttr(attrs, ["http.response.status_code", "http.status_code", "http.response.status_class"]),
spanColumnAttr(attrs, ["workbench.ui.value_ms"]),
spanColumnAttr(attrs, ["workbench.ui.resource_duration_ms"]),
spanColumnAttr(attrs, ["workbench.ui.resource_fetch_to_request_ms"]),
spanColumnAttr(attrs, ["workbench.ui.resource_request_wait_ms"]),
spanColumnAttr(attrs, ["workbench.ui.resource_response_transfer_ms"]),
shortenEnd(spanColumnAttr(attrs, ["workbench.ui.resource_next_hop_protocol"]), 14),
spanDetail(span, 220),
];
});
const countRows = asArray(input.result.spanNameCounts).slice(0, 8).map((item) => {
@@ -856,7 +865,7 @@ function renderTraceTable(input: {
formatTable(["FIELD", "VALUE"], identityRows.length > 0 ? identityRows : [["-", "-"]]),
"",
"Key spans:",
formatTable(["NAME", "SERVICE", "DETAIL"], spanRows.length > 0 ? spanRows : [["-", "-", "-"]]),
formatTable(["NAME", "SERVICE", "ROUTE", "STATUS", "VALUE_MS", "RES_MS", "FETCH_REQ", "REQ_WAIT", "RESP_XFER", "PROTO", "DETAIL"], spanRows.length > 0 ? spanRows : [["-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"]]),
"",
"Span name counts:",
formatTable(["NAME", "COUNT"], countRows.length > 0 ? countRows : [["-", "-"]]),
@@ -1037,6 +1046,16 @@ function uniqueSpanRecords(values: unknown[]): Record<string, unknown>[] {
return rows;
}
function spanColumnAttr(attrs: Record<string, unknown> | null, keys: string[]): string {
if (attrs === null) return "-";
for (const key of keys) {
const value = attrs[key];
const text = textValue(value);
if (text !== "-") return text;
}
return "-";
}
function spanDetail(span: Record<string, unknown>, maxLength: number): string {
const attrs = asPlainRecord(span.attributes);
const parts = [