Called from the FastAPI lifespan startup hook. Failure to configure is logged and swallowed - the API must start whether or not the analytics sinks are reachable.
()
| 122 | |
| 123 | |
| 124 | async def start() -> None: |
| 125 | """ |
| 126 | Called from the FastAPI lifespan startup hook. |
| 127 | |
| 128 | Failure to configure is logged and swallowed - the API must start whether |
| 129 | or not the analytics sinks are reachable. |
| 130 | """ |
| 131 | global _queue, _writer_task |
| 132 | |
| 133 | if not os.environ.get("R2_ACCOUNT_ID"): |
| 134 | logger.info("R2 not configured; usage logging disabled") |
| 135 | return |
| 136 | |
| 137 | _queue = asyncio.Queue(maxsize=QUEUE_MAXSIZE) |
| 138 | _writer_task = asyncio.create_task(_writer_loop()) |
| 139 | logger.info( |
| 140 | f"Usage logging started (host={HOST_ID}, " |
| 141 | f"batch={BATCH_SIZE}/{BATCH_INTERVAL}s)" |
| 142 | ) |
| 143 | |
| 144 | |
| 145 | async def stop() -> None: |
nothing calls this directly
no test coverage detected