wrangler.jsonc 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // codegraph telemetry ingest — see README.md and docs/design/telemetry.md.
  2. // Accepted events go straight into the bound D1 database and the worker makes no
  3. // outbound requests. The only secret is ADMIN_TOKEN, which guards the manual rollup
  4. // trigger (`wrangler secret put ADMIN_TOKEN`); leave it unset and that route 404s.
  5. {
  6. "$schema": "node_modules/wrangler/config-schema.json",
  7. "name": "codegraph-telemetry",
  8. "main": "src/index.ts",
  9. "compatibility_date": "2026-06-12",
  10. "compatibility_flags": ["nodejs_compat"],
  11. // First-party endpoint. The custom domain auto-provisions DNS + cert when the
  12. // getcodegraph.com zone is on the deploying account. workers.dev stays off so
  13. // the only public surface is the documented one.
  14. "routes": [{ "pattern": "telemetry.getcodegraph.com", "custom_domain": true }],
  15. "workers_dev": false,
  16. "observability": { "enabled": true, "head_sampling_rate": 1 },
  17. // Nightly rollup + retention purge (src/rollup.ts). 00:30 UTC — half an hour after
  18. // the day it rolls up closed, so straggling writes for it have landed. It also
  19. // re-runs the two days before that, because offline clients ship completed-day
  20. // rollups late; the writes are idempotent upserts, so re-running is free.
  21. "triggers": { "crons": ["30 0 * * *"] },
  22. // How many days of RAW events are kept. Rollups are kept forever, so shortening
  23. // this costs ad-hoc drill-back, never a chart. 90 is a storage limit, not a policy
  24. // one: raw events grow ≈74 MB/day, so 90 days ≈ 6.7 GB against D1's 10 GB
  25. // per-database cap — the arithmetic is in migrations/0001_init.sql's footer.
  26. // Measure real row size after cutover before widening it.
  27. "vars": { "RETENTION_DAYS": 90 },
  28. // Telemetry storage. Schema + the chart each table serves: migrations/0001_init.sql.
  29. // Apply with `npm run db:migrate:local` (local state) / `npm run db:migrate` (remote).
  30. // The admin dashboard worker binds this same database read-mostly, also as `DB`.
  31. "d1_databases": [
  32. {
  33. "binding": "DB",
  34. "database_name": "codegraph-telemetry",
  35. "database_id": "5ed36dfb-d2d7-4e35-9e63-a1b99d0b1ed3",
  36. "migrations_dir": "migrations"
  37. }
  38. ],
  39. // Per-machine_id rate limit. Legit clients flush a handful of times per day;
  40. // 6/min absorbs install+index bursts while capping abuse.
  41. "ratelimits": [
  42. {
  43. "name": "MACHINE_RATE_LIMITER",
  44. "namespace_id": "1001",
  45. "simple": { "limit": 6, "period": 60 }
  46. },
  47. // POST /admin/rollup. The ADMIN_TOKEN secret is the real guard; this only caps
  48. // how fast it can be guessed at, with enough room for a chunked backfill loop.
  49. {
  50. "name": "ADMIN_RATE_LIMITER",
  51. "namespace_id": "1002",
  52. "simple": { "limit": 10, "period": 60 }
  53. }
  54. ]
  55. }