search for standard sites pub-search.waow.tech
search zig blog atproto
11
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: simplify scripts now that logfire handles observability

- remove diagnose-latency.py (logfire shows latency distributions)
- simplify exercise-api to just hit endpoints, point to logfire for results

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

zzstoatzz 8f16fd6f a0a90452

+4 -65
-51
scripts/diagnose-latency.py
··· 1 - #!/usr/bin/env python3 2 - """diagnose search API latency""" 3 - 4 - import time 5 - import httpx 6 - 7 - BASE_URL = "https://leaflet-search-backend.fly.dev" 8 - 9 - def timed_request(url: str, name: str) -> float: 10 - start = time.perf_counter() 11 - resp = httpx.get(url, timeout=30) 12 - elapsed = time.perf_counter() - start 13 - print(f"{name}: {elapsed:.3f}s (status={resp.status_code})") 14 - return elapsed 15 - 16 - def main(): 17 - print("=== latency diagnosis ===\n") 18 - 19 - # warmup 20 - print("1. warmup request (health):") 21 - timed_request(f"{BASE_URL}/health", " health") 22 - 23 - print("\n2. first search (cold db?):") 24 - t1 = timed_request(f"{BASE_URL}/search?q=atproto", " search") 25 - 26 - print("\n3. rapid follow-up searches:") 27 - times = [] 28 - for i in range(5): 29 - t = timed_request(f"{BASE_URL}/search?q=blog", f" search {i+1}") 30 - times.append(t) 31 - 32 - print(f"\n4. stats (single query):") 33 - timed_request(f"{BASE_URL}/stats", " stats") 34 - 35 - print(f"\n5. dashboard (batched queries):") 36 - timed_request(f"{BASE_URL}/api/dashboard", " dashboard") 37 - 38 - print("\n=== summary ===") 39 - print(f"first search: {t1:.3f}s") 40 - print(f"follow-up avg: {sum(times)/len(times):.3f}s") 41 - print(f"follow-up min: {min(times):.3f}s") 42 - print(f"follow-up max: {max(times):.3f}s") 43 - 44 - if t1 > 5: 45 - print("\n⚠️ first request very slow - likely turso cold start") 46 - if sum(times)/len(times) > 1: 47 - print("⚠️ follow-up requests still slow - query optimization needed") 48 - print(" suggestion: batch the 3 search queries into 1 http request") 49 - 50 - if __name__ == "__main__": 51 - main()
+4 -14
scripts/exercise-api
··· 4 4 # dependencies = ["httpx"] 5 5 # /// 6 6 """ 7 - Exercise all leaflet-search API endpoints to generate traffic for stats. 7 + Exercise all leaflet-search API endpoints to generate traffic. 8 8 9 9 Usage: 10 10 ./scripts/exercise-api # run with defaults 11 11 ./scripts/exercise-api --count 20 # more requests per endpoint 12 + 13 + Check logfire for latency/error data after running. 12 14 """ 13 15 14 16 import asyncio ··· 98 100 exercise_popular(client, count), 99 101 ) 100 102 101 - print("\nfetching stats...") 102 - async with httpx.AsyncClient(base_url=BASE_URL, timeout=30) as client: 103 - resp = await client.get("/api/dashboard") 104 - data = resp.json() 105 - timing = data.get("timing", {}) 106 - print("\nendpoint count p50 p95") 107 - print("-" * 40) 108 - for name in ["search", "similar", "tags", "popular"]: 109 - t = timing.get(name, {}) 110 - c = t.get("count", 0) 111 - p50 = t.get("p50_ms", 0) 112 - p95 = t.get("p95_ms", 0) 113 - print(f"{name:<12} {c:<6} {p50:>6.0f}ms {p95:>6.0f}ms") 103 + print("\ndone - check logfire for results") 114 104 115 105 116 106 if __name__ == "__main__":