(
self,
storage: TraceStorage | None = None,
now_fn: Any = None,
*,
hot_days: int | None = None,
)
| 334 | |
| 335 | class TraceStore: |
| 336 | def __init__( |
| 337 | self, |
| 338 | storage: TraceStorage | None = None, |
| 339 | now_fn: Any = None, |
| 340 | *, |
| 341 | hot_days: int | None = None, |
| 342 | ) -> None: |
| 343 | if storage is None: |
| 344 | target_dir = data_dir() / "traces" |
| 345 | legacy = data_dir() / "traces.json" |
| 346 | try: |
| 347 | migrate_legacy_json(legacy, target_dir) |
| 348 | except Exception: |
| 349 | pass |
| 350 | storage = FileTraceStorage(base_dir=target_dir) |
| 351 | self._storage = storage |
| 352 | self._now = now_fn or time.time |
| 353 | if hot_days is None: |
| 354 | try: |
| 355 | hot_days = int(os.environ.get("UNCOMMON_ROUTE_TRACE_HOT_DAYS", "2")) |
| 356 | except Exception: |
| 357 | hot_days = 2 |
| 358 | self._hot_days = max(1, hot_days) |
| 359 | self._records: list[RequestTrace] = [] |
| 360 | self._load() |
| 361 | |
| 362 | @property |
| 363 | def count(self) -> int: |
nothing calls this directly
no test coverage detected