| 17 | |
| 18 | @dataclass |
| 19 | class Sample: |
| 20 | path: Path |
| 21 | line_no: int |
| 22 | raw: dict[str, Any] |
| 23 | timestamp_ms: int |
| 24 | kind: str |
| 25 | target: str |
| 26 | instance_id: str |
| 27 | source: str |
| 28 | trigger_category: str |
| 29 | trigger_reason: str |
| 30 | sessions: dict[str, Any] | None |
| 31 | totals: dict[str, Any] | None |
| 32 | |
| 33 | @property |
| 34 | def pss_bytes(self) -> int | None: |
| 35 | os_info = self.raw.get("process", {}).get("os") or {} |
| 36 | value = os_info.get("pss_bytes") |
| 37 | return int(value) if isinstance(value, int | float) else None |
| 38 | |
| 39 | @property |
| 40 | def rss_bytes(self) -> int | None: |
| 41 | value = self.raw.get("process", {}).get("rss_bytes") |
| 42 | return int(value) if isinstance(value, int | float) else None |
| 43 | |
| 44 | @property |
| 45 | def allocator_allocated_bytes(self) -> int | None: |
| 46 | value = (((self.raw.get("process") or {}).get("allocator") or {}).get("stats") or {}).get( |
| 47 | "allocated_bytes" |
| 48 | ) |
| 49 | return int(value) if isinstance(value, int | float) else None |
| 50 | |
| 51 | @property |
| 52 | def allocator_resident_bytes(self) -> int | None: |
| 53 | value = (((self.raw.get("process") or {}).get("allocator") or {}).get("stats") or {}).get( |
| 54 | "resident_bytes" |
| 55 | ) |
| 56 | return int(value) if isinstance(value, int | float) else None |
| 57 | |
| 58 | @property |
| 59 | def allocator_retained_bytes(self) -> int | None: |
| 60 | value = (((self.raw.get("process") or {}).get("allocator") or {}).get("stats") or {}).get( |
| 61 | "retained_bytes" |
| 62 | ) |
| 63 | return int(value) if isinstance(value, int | float) else None |
| 64 | |
| 65 | @property |
| 66 | def os_info(self) -> dict[str, Any]: |
| 67 | value = (self.raw.get("process") or {}).get("os") |
| 68 | return value if isinstance(value, dict) else {} |
| 69 | |
| 70 | @property |
| 71 | def process_info(self) -> dict[str, Any]: |
| 72 | value = self.raw.get("process") |
| 73 | return value if isinstance(value, dict) else {} |
| 74 | |
| 75 | @property |
| 76 | def process_diagnostics(self) -> dict[str, Any]: |