MCPcopy Create free account
hub / github.com/Roy3838/Observer / start

Function start

api/usage_log.py:124–142  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

122
123
124async 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
145async def stop() -> None:

Callers

nothing calls this directly

Calls 2

_writer_loopFunction · 0.85
infoMethod · 0.80

Tested by

no test coverage detected