Streams synthetic predict requests so you can see INFO / WARNING / ERROR in real time. Tune the knobs and watch the log surface react.
import logging, random, time
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s %(message)s",
)
SLOW_MS = 500
ERROR_RATE = 0.03
def predict(req_id):
latency = random.gauss(180, 60)
logging.info(f"predict req_id={req_id} latency_ms={latency:.0f}")
if latency > SLOW_MS:
logging.warning(f"slow predict req_id={req_id} latency_ms={latency:.0f}")
if random.random() < ERROR_RATE:
logging.error(f"model failure req_id={req_id}")
for i in range(50):
predict(f"r{i:03d}")
time.sleep(0.2)