feat: 收敛 Sub2API 账号调优诊断
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
export function runtimeRemoteScriptTail(): string {
|
||||
return `def native_customer_error_profile(token, group_id, platform):
|
||||
return `def native_customer_error_profile(token, group_id, platform, account_ids=None):
|
||||
start_time = quote(since_start_time(PAYLOAD.get("since")), safe="")
|
||||
platform_query = "&platform=" + quote(str(platform), safe="") if platform else ""
|
||||
page = 1
|
||||
@@ -11,7 +11,8 @@ export function runtimeRemoteScriptTail(): string {
|
||||
response = curl_api("GET", f"/api/v1/admin/ops/request-errors?group_id={group_id}&start_time={start_time}&view=all&page={page}&page_size={page_size}{platform_query}", bearer=token)
|
||||
data = data_of(response, "get customer-visible request errors")
|
||||
page_rows = items_of(data)
|
||||
rows.extend(page_rows)
|
||||
selected_rows = [row for row in page_rows if not account_ids or str(row.get("account_id")) in account_ids]
|
||||
rows.extend(selected_rows)
|
||||
if total is None and isinstance(data, dict) and isinstance(data.get("total"), int):
|
||||
total = data.get("total")
|
||||
if not page_rows or len(page_rows) < page_size or (isinstance(total, int) and len(rows) >= total):
|
||||
@@ -19,7 +20,9 @@ export function runtimeRemoteScriptTail(): string {
|
||||
page += 1
|
||||
except Exception as exc:
|
||||
return {"status": "unavailable", "source": "sub2api-native-admin-ops-request-errors", "reason": compact_error(str(exc))}
|
||||
if total is None:
|
||||
if account_ids:
|
||||
total = len(rows)
|
||||
elif total is None:
|
||||
total = len(rows)
|
||||
def buckets(key_fn):
|
||||
counts = {}
|
||||
@@ -273,6 +276,7 @@ def account_quality_scores(token, accounts, group_id, native_ops, effectiveness)
|
||||
rows.append({
|
||||
"accountId": account_id, "accountName": account.get("name"), "status": account.get("status"),
|
||||
"schedulable": account.get("schedulable"), "currentlyAvailable": current_available,
|
||||
"priority": account.get("priority"), "priorityOrder": "lower-is-higher",
|
||||
"score": score, "grade": grade, "assessment": assessment, "confidence": confidence,
|
||||
"scoreComparable": score_comparable,
|
||||
"observedAttempts": observed_attempts, "successRequests": success_requests,
|
||||
@@ -816,7 +820,7 @@ def observed_runtime_errors(token, accounts, group_id, platform=None):
|
||||
overview_summary = ((native_ops.get("overview") or {}).get("summary") or {})
|
||||
native_ops["responseHeaderTimeout"] = runtime_response_header_timeout()
|
||||
native_ops["requestTiming"] = native_request_timing(token, group_id, platform, overview_summary)
|
||||
native_ops["customerErrors"] = native_customer_error_profile(token, group_id, platform)
|
||||
native_ops["customerErrors"] = native_customer_error_profile(token, group_id, platform, selected_ids if selector is not None else None)
|
||||
native_ops["accountQuality"] = account_quality_scores(token, selected, group_id, native_ops, effectiveness)
|
||||
request_total = overview_summary.get("request_count_total")
|
||||
error_total = overview_summary.get("error_count_total")
|
||||
@@ -1204,7 +1208,7 @@ def runtime_result():
|
||||
return {**base, "ok": True, "operation": "errors", "mutation": False, "errors": errors}
|
||||
detail = find_account(token, accounts, str(PAYLOAD["account"])) if action in ("get", "infrastructure") else None
|
||||
if action == "get":
|
||||
return {**base, "ok": True, "operation": "get", "mutation": False, "account": account_summary(detail, True)}
|
||||
return {**base, "ok": True, "operation": "get", "mutation": False, "account": account_summary(detail, True, token)}
|
||||
if action == "infrastructure":
|
||||
return {
|
||||
**base,
|
||||
|
||||
Reference in New Issue
Block a user