Add system arch data to debug output

This commit is contained in:
Jack Kingsman
2026-03-31 23:09:12 -07:00
parent 480798e117
commit 416166b07c

View File

@@ -1,5 +1,8 @@
import hashlib
import logging
import os
import platform
import struct
import sys
from datetime import datetime, timezone
from typing import Any
@@ -34,6 +37,13 @@ LOG_COPY_BOUNDARY_PREFIX = [
]
class DebugSystemInfo(BaseModel):
os: str
arch: str
arch_bits: int
total_ram_mb: int
class DebugApplicationInfo(BaseModel):
version: str
version_source: str
@@ -95,6 +105,7 @@ class DebugDatabaseInfo(BaseModel):
class DebugSnapshotResponse(BaseModel):
captured_at: str
system: DebugSystemInfo
application: DebugApplicationInfo
health: HealthResponse
runtime: DebugRuntimeInfo
@@ -103,6 +114,23 @@ class DebugSnapshotResponse(BaseModel):
logs: list[str]
def _build_system_info() -> DebugSystemInfo:
try:
# os.sysconf is available on Linux/macOS
page_size = os.sysconf("SC_PAGE_SIZE")
page_count = os.sysconf("SC_PHYS_PAGES")
total_ram_mb = (page_size * page_count) // (1024 * 1024)
except (AttributeError, ValueError, OSError):
total_ram_mb = 0
return DebugSystemInfo(
os=f"{platform.system()} {platform.release()}",
arch=platform.machine(),
arch_bits=struct.calcsize("P") * 8,
total_ram_mb=total_ram_mb,
)
def _build_application_info() -> DebugApplicationInfo:
build_info = get_app_build_info()
dirty_output = git_output("status", "--porcelain")
@@ -272,6 +300,7 @@ async def debug_support_snapshot() -> DebugSnapshotResponse:
)
return DebugSnapshotResponse(
captured_at=datetime.now(timezone.utc).isoformat(),
system=_build_system_info(),
application=_build_application_info(),
health=HealthResponse(**health_data),
runtime=DebugRuntimeInfo(