MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / buffer_record

Function buffer_record

uncommon_route/telemetry.py:231–244  ·  view source on GitHub ↗

Append a completed record to the local buffer.

(record: TelemetryRecord)

Source from the content-addressed store, hash-verified

229
230
231def buffer_record(record: TelemetryRecord) -> None:
232 """Append a completed record to the local buffer."""
233 if not is_enabled():
234 return
235 try:
236 buf = _buffer_path()
237 buf.parent.mkdir(parents=True, exist_ok=True)
238 with open(buf, "a", encoding="utf-8") as f:
239 f.write(json.dumps(record.to_dict(), ensure_ascii=False) + "\n")
240
241 # NO auto-flush here — flush only on explicit command or shutdown
242 # This keeps telemetry off the hot routing path (no blocking network calls)
243 except Exception as e:
244 logger.debug("Telemetry buffer failed: %s", e)
245
246
247def flush() -> int:

Callers

nothing calls this directly

Calls 4

is_enabledFunction · 0.85
_buffer_pathFunction · 0.85
openFunction · 0.85
to_dictMethod · 0.45

Tested by

no test coverage detected