feat: show request payload size
This commit is contained in:
@@ -346,9 +346,13 @@ def format_duration_ms_as_seconds(value: Any) -> str:
|
||||
|
||||
|
||||
def format_bytes(value: Any) -> str:
|
||||
number = as_int(value)
|
||||
if number <= 0:
|
||||
if value is None or str(value).strip() == "":
|
||||
return "-"
|
||||
number = as_int(value)
|
||||
if number < 0:
|
||||
return "-"
|
||||
if number == 0:
|
||||
return "0B"
|
||||
if number >= 1_000_000:
|
||||
return f"{number / 1_000_000:.1f}MB".rstrip("0").rstrip(".")
|
||||
if number >= 1_000:
|
||||
@@ -478,7 +482,8 @@ def request_row_cells(row: dict[str, Any], text_limits: dict[str, int] | None =
|
||||
short_text(row["model"] or row["requested_model"] or row["forwarded_model"], limits.get("model", 16)),
|
||||
row["reasoning_tokens"] if row["reasoning_tokens"] is not None else "-",
|
||||
short_text(request_usage_summary(row), limits.get("usage", 24)),
|
||||
format_bytes(row["response_bytes_received"]),
|
||||
format_bytes(row.get("request_body_bytes")),
|
||||
format_bytes(row.get("response_bytes_received")),
|
||||
request_chunk_progress(row),
|
||||
format_duration_ms_as_seconds(row["first_response_delay_ms"]),
|
||||
format_duration_ms_as_seconds(row["duration_ms"]),
|
||||
@@ -781,8 +786,8 @@ def render_request_detail(row: dict[str, Any]) -> str:
|
||||
f"attempts {row['upstream_attempt_count'] or 0}",
|
||||
f"first {format_duration_ms_as_seconds(row['first_response_delay_ms'])}",
|
||||
f"duration {format_duration_ms_as_seconds(row['duration_ms'])}",
|
||||
f"request {format_bytes(row['request_body_bytes'])}",
|
||||
f"response {format_bytes(row['response_bytes_received'])}",
|
||||
f"request {format_bytes(row.get('request_body_bytes'))}",
|
||||
f"response {format_bytes(row.get('response_bytes_received'))}",
|
||||
f"chunks {row['stream_chunk_count'] or 0}",
|
||||
f"life {request_lifecycle_label(row)}",
|
||||
f"finished {short_time(row['finished_at'])}",
|
||||
@@ -1217,6 +1222,7 @@ def run_textual(
|
||||
"model": 16,
|
||||
"reasoning": 10,
|
||||
"usage": 36,
|
||||
"req": 10,
|
||||
"resp": 10,
|
||||
"chunks": 14,
|
||||
"first": 8,
|
||||
@@ -1234,6 +1240,7 @@ def run_textual(
|
||||
"model": 24,
|
||||
"reasoning": 10,
|
||||
"usage": 72,
|
||||
"req": 12,
|
||||
"resp": 12,
|
||||
"chunks": 16,
|
||||
"first": 8,
|
||||
@@ -1273,6 +1280,7 @@ def run_textual(
|
||||
"model": requests.add_column("Model", width=width_profile["model"], key="model"),
|
||||
"reasoning": requests.add_column("Reasoning", width=width_profile["reasoning"], key="reasoning"),
|
||||
"usage": requests.add_column("Usage", width=self.request_usage_width, key="usage"),
|
||||
"req": requests.add_column("Req", width=width_profile["req"], key="req"),
|
||||
"resp": requests.add_column("Resp", width=width_profile["resp"], key="resp"),
|
||||
"chunks": requests.add_column("Chunks", width=width_profile["chunks"], key="chunks"),
|
||||
"first": requests.add_column("First", width=width_profile["first"], key="first"),
|
||||
@@ -1785,7 +1793,7 @@ def print_once(snapshot: dict[str, Any], filter_text: str = "") -> None:
|
||||
print(
|
||||
f"{row['seq']:>6} {short_text(primary_request_id(row), 16):<16} {short_text(row.get('thread_id'), 14):<14} {short_time(row.get('started_at')):<19} {status_symbol(row)} {row.get('status_code') or '-':<4} "
|
||||
f"{short_text(row['path'], 20):<20} {short_text(row['model'] or row['requested_model'] or row['forwarded_model'], 16):<16} "
|
||||
f"{short_text(request_usage_summary(row), 26):<26} {request_chunk_progress(row):<14} {format_duration_ms_as_seconds(row['duration_ms']):<8} {request_updated_elapsed(row):<8} "
|
||||
f"{short_text(request_usage_summary(row), 26):<26} {format_bytes(row.get('request_body_bytes')):<8} {request_chunk_progress(row):<14} {format_duration_ms_as_seconds(row['duration_ms']):<8} {request_updated_elapsed(row):<8} "
|
||||
f"{format_count(row['upstream_attempt_count'] or 0):<4} {short_text(row['error'], 30)}"
|
||||
)
|
||||
except BrokenPipeError:
|
||||
|
||||
Reference in New Issue
Block a user