fix: surface provider decision in otel diagnostics
This commit is contained in:
@@ -382,6 +382,7 @@ export function renderTraceTable(input: {
|
||||
const turnRows = traceTurnStatusRows(allSpans);
|
||||
const projectionRows = traceProjectionRows(allSpans);
|
||||
const projectionSyncRows = traceProjectionSyncRows(allSpans);
|
||||
const providerRows = traceProviderDecisionRows(allSpans);
|
||||
const countRows = asArray(input.result.spanNameCounts).slice(0, 8).map((item) => {
|
||||
const row = asPlainRecord(item) ?? {};
|
||||
return [shortenEnd(textValue(row.name), 64), textValue(row.count)];
|
||||
@@ -406,6 +407,9 @@ export function renderTraceTable(input: {
|
||||
"Identity:",
|
||||
formatTable(["FIELD", "VALUE"], identityRows.length > 0 ? identityRows : [["-", "-"]]),
|
||||
"",
|
||||
"Provider decision:",
|
||||
formatTable(["SERVICE", "PROFILE", "SOURCE", "DEFAULT", "MODEL", "ADAPTER", "RUNNER_NS", "SESSION"], providerRows.length > 0 ? providerRows : [["-", "-", "-", "-", "-", "-", "-", "-"]]),
|
||||
"",
|
||||
"Key spans:",
|
||||
formatTable(["NAME", "SERVICE", "ROUTE", "STATUS", "DUR_MS", "RES_MS", "FETCH_REQ", "REQ_WAIT", "RESP_XFER", "PROTO", "DETAIL"], spanRows.length > 0 ? spanRows : [["-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"]]),
|
||||
"",
|
||||
@@ -483,6 +487,27 @@ function traceRunnerRows(spans: Record<string, unknown>[]): string[][] {
|
||||
return dedupeRows(rows).slice(0, 12);
|
||||
}
|
||||
|
||||
function traceProviderDecisionRows(spans: Record<string, unknown>[]): string[][] {
|
||||
const rows = spans.filter((span) => {
|
||||
const attrs = asPlainRecord(span.attributes);
|
||||
return textValue(span.name) === "provider_decision"
|
||||
|| spanColumnAttr(attrs, ["agent.chat.provider_profile", "providerProfile", "defaultProviderProfile"]) !== "-";
|
||||
}).map((span) => {
|
||||
const attrs = asPlainRecord(span.attributes);
|
||||
return [
|
||||
shortenEnd(textValue(span.service), 20),
|
||||
shortenEnd(spanColumnAttr(attrs, ["agent.chat.provider_profile", "providerProfile", "backendProfile", "defaultProviderProfile"]), 22),
|
||||
shortenEnd(spanColumnAttr(attrs, ["agent.chat.provider_profile_source", "providerProfileSource"]), 12),
|
||||
shortenEnd(spanColumnAttr(attrs, ["defaultProviderProfile"]), 22),
|
||||
shortenEnd(spanColumnAttr(attrs, ["agent.chat.model", "agent.chat.model_id", "agent.chat.provider_model", "model", "modelId", "providerModel"]), 28),
|
||||
shortenEnd(spanColumnAttr(attrs, ["adapter"]), 16),
|
||||
shortenEnd(spanColumnAttr(attrs, ["agentRunRunnerNamespace"]), 16),
|
||||
shortenMiddle(spanColumnAttr(attrs, ["agent.chat.session_id", "sessionId", "workbench.session_id"]), 24),
|
||||
];
|
||||
});
|
||||
return dedupeRows(rows).slice(0, 8);
|
||||
}
|
||||
|
||||
function traceReadWindowRows(spans: Record<string, unknown>[]): string[][] {
|
||||
const rows = spans.filter((span) => textValue(span.name) === "trace_events_read").map((span) => {
|
||||
const attrs = asPlainRecord(span.attributes);
|
||||
@@ -678,6 +703,7 @@ export function renderDiagnoseCodeAgentTable(input: {
|
||||
const evidence = asPlainRecord(input.result.evidence);
|
||||
const observabilityGap = asPlainRecord(input.result.observabilityGap);
|
||||
const servicePath = asPlainRecord(input.result.servicePath);
|
||||
const providerDecision = asPlainRecord(input.result.providerDecision);
|
||||
const rootCauses = asArray(input.result.rootCauseCandidates).map((item) => asPlainRecord(item) ?? {});
|
||||
const http = asPlainRecord(input.result.http);
|
||||
const services = joinValues(input.result.services, 54);
|
||||
@@ -727,6 +753,7 @@ export function renderDiagnoseCodeAgentTable(input: {
|
||||
` requested runId=${requestedRunId} commandId=${requestedCommandId} sessionId=${requestedSessionId} runnerJobId=${requestedRunnerJobId}`,
|
||||
` observed runId=${observedRunId} commandId=${observedCommandId} sessionId=${observedSessionId} runnerJobId=${observedRunnerJobId} runnerId=${textValue(identity?.runnerId)}`,
|
||||
` backendProfile=${textValue(identity?.backendProfile)} sourceCommit=${shortenMiddle(textValue(identity?.sourceCommit), 20)}`,
|
||||
` providerProfile=${textValue(providerDecision?.providerProfile)} model=${textValue(providerDecision?.model)} source=${textValue(providerDecision?.providerProfileSource)} adapter=${textValue(providerDecision?.adapter)} runnerNamespace=${textValue(providerDecision?.runnerNamespace)}`,
|
||||
"",
|
||||
"Root causes:",
|
||||
formatTable(["CODE", "CONF", "SUMMARY"], rootRows.length > 0 ? rootRows : [["-", "-", "-"]]),
|
||||
|
||||
Reference in New Issue
Block a user