fix: improve observability code agent diagnosis
This commit is contained in:
@@ -767,12 +767,13 @@ function diagnoseSearchFilters(options: DiagnoseCodeAgentOptions): string[] {
|
||||
if (options.businessTraceId !== null) filters.push(`.traceId = ${JSON.stringify(options.businessTraceId)}`);
|
||||
if (options.runId !== null) filters.push(`.runId = ${JSON.stringify(options.runId)}`);
|
||||
if (options.commandId !== null) filters.push(`.commandId = ${JSON.stringify(options.commandId)}`);
|
||||
if (options.sessionId !== null) filters.push(`.sessionId = ${JSON.stringify(options.sessionId)}`);
|
||||
if (options.runnerJobId !== null) filters.push(`.runnerJobId = ${JSON.stringify(options.runnerJobId)}`);
|
||||
return filters;
|
||||
}
|
||||
|
||||
function diagnoseSearchMode(options: DiagnoseCodeAgentOptions): string {
|
||||
if (options.businessTraceId !== null && options.runId === null && options.commandId === null && options.runnerJobId === null) return "business-trace-id";
|
||||
if (options.businessTraceId !== null && options.runId === null && options.commandId === null && options.sessionId === null && options.runnerJobId === null) return "business-trace-id";
|
||||
if (options.traceId !== null) return "trace-id";
|
||||
return "trace-attribute-query";
|
||||
}
|
||||
@@ -783,6 +784,7 @@ function buildDiagnoseCodeAgentCommand(target: ObservabilityTarget, options: Dia
|
||||
if (options.traceId !== null) parts.push("--trace-id", options.traceId);
|
||||
if (options.runId !== null) parts.push("--run-id", options.runId);
|
||||
if (options.commandId !== null) parts.push("--command-id", options.commandId);
|
||||
if (options.sessionId !== null) parts.push("--session-id", options.sessionId);
|
||||
if (options.runnerJobId !== null) parts.push("--runner-job-id", options.runnerJobId);
|
||||
parts.push("--lookback-minutes", String(options.lookbackMinutes), "--candidate-limit", String(options.candidateLimit), "--limit", String(options.limit));
|
||||
if (full) parts.push("--full");
|
||||
@@ -817,6 +819,7 @@ export function diagnoseCodeAgentScript(observability: ObservabilityConfig, targ
|
||||
const businessTraceIdLiteral = options.businessTraceId === null ? "None" : JSON.stringify(options.businessTraceId);
|
||||
const runIdLiteral = options.runId === null ? "None" : JSON.stringify(options.runId);
|
||||
const commandIdLiteral = options.commandId === null ? "None" : JSON.stringify(options.commandId);
|
||||
const sessionIdLiteral = options.sessionId === null ? "None" : JSON.stringify(options.sessionId);
|
||||
const runnerJobIdLiteral = options.runnerJobId === null ? "None" : JSON.stringify(options.runnerJobId);
|
||||
const searchPathLiteral = searchPath === null ? "None" : JSON.stringify(searchPath);
|
||||
const searchProxyPathLiteral = searchProxyPath === null ? "None" : JSON.stringify(searchProxyPath);
|
||||
@@ -836,6 +839,7 @@ BUSINESS_TRACE_ID = ${businessTraceIdLiteral}
|
||||
TRACE_ID = ${traceIdLiteral}
|
||||
RUN_ID = ${runIdLiteral}
|
||||
COMMAND_ID = ${commandIdLiteral}
|
||||
SESSION_ID = ${sessionIdLiteral}
|
||||
RUNNER_JOB_ID = ${runnerJobIdLiteral}
|
||||
TARGET_ID = ${JSON.stringify(target.id)}
|
||||
SEARCH_MODE = ${JSON.stringify(searchMode)}
|
||||
@@ -1781,7 +1785,7 @@ def candidate_score(trace_id, meta, trace_body, trace_rc, trace_err):
|
||||
span_points = min(len(spans), 80)
|
||||
if span_points:
|
||||
add(span_points, "span count %s" % len(spans))
|
||||
for key, points in (("runId", 50), ("commandId", 50), ("runnerJobId", 35), ("runnerId", 30), ("attemptId", 20), ("backendProfile", 15)):
|
||||
for key, points in (("runId", 50), ("commandId", 50), ("sessionId", 35), ("runnerJobId", 35), ("runnerId", 30), ("attemptId", 20), ("backendProfile", 15)):
|
||||
if identity.get(key) not in (None, ""):
|
||||
add(points, "identity %s" % key)
|
||||
if any("codex_stdio" in name for name in lowered_names):
|
||||
@@ -1821,7 +1825,7 @@ def candidate_score(trace_id, meta, trace_body, trace_rc, trace_err):
|
||||
"spanCount": len(spans),
|
||||
"services": sorted(services),
|
||||
"servicePath": service_path,
|
||||
"identity": {key: identity.get(key) for key in ("runId", "commandId", "runnerJobId", "runnerId", "backendProfile") if identity.get(key) not in (None, "")},
|
||||
"identity": {key: identity.get(key) for key in ("runId", "commandId", "sessionId", "runnerJobId", "runnerId", "backendProfile") if identity.get(key) not in (None, "")},
|
||||
"terminalStatus": agentrun.get("terminalStatus"),
|
||||
"errorSpanCount": len(error_spans),
|
||||
"candidateQuality": candidate_quality,
|
||||
@@ -1839,6 +1843,7 @@ def resolve_trace():
|
||||
"businessTraceId": BUSINESS_TRACE_ID,
|
||||
"runId": RUN_ID,
|
||||
"commandId": COMMAND_ID,
|
||||
"sessionId": SESSION_ID,
|
||||
"runnerJobId": RUNNER_JOB_ID,
|
||||
"otelTraceId": TRACE_ID,
|
||||
"searchQuery": SEARCH_QUERY,
|
||||
@@ -1898,6 +1903,7 @@ def resolve_trace():
|
||||
"businessTraceId": BUSINESS_TRACE_ID,
|
||||
"runId": RUN_ID,
|
||||
"commandId": COMMAND_ID,
|
||||
"sessionId": SESSION_ID,
|
||||
"runnerJobId": RUNNER_JOB_ID,
|
||||
"otelTraceId": selected_trace_id,
|
||||
"searchQuery": SEARCH_QUERY,
|
||||
|
||||
Reference in New Issue
Block a user